Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 10th, 2005, 10:44 PM   #1
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
nested array confusion :S

hey,

this kinda branches off my "optimization help" thread, but concerns regular arrays.

here's the scenario: eight buttons are in a control array, the name of which is "cmdKw." when the user clicks on any button, it loads some stuff into the corresponding listbox that is part of another control array, named "lstKw."

what i'm having trouble with is that i want to copy the contents of each listbox to an array of strings, but have all those arrays of strings as part of a master array so i can refer to it using the same index value as cmdKw and lstKw use.

so to put it in action:

the user clicks on cmdKw(3). listbox lstKw(3) gets populated with a variable amount of text (and thus does not have a static listcount). now i want to copy each entry from lstKw(3) into arrayKw(3).

i guess what i'm not understanding is how to set up (and redim if necessary) a subarray. the msdn entry for arrays doesn't quite explain subarrays that verbosely.

thanks
chepfaust is offline   Reply With Quote
Old Mar 11th, 2005, 6:11 PM   #2
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
haha i love the taste of success after a long bout of trial and error.

none of my arrays were working because i was dimming the parent array as string; now when i dimmed the parent array as variant, it works beautifully.
chepfaust is offline   Reply With Quote
Old Mar 12th, 2005, 3:08 PM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
That's odd... it should work fine with strings too. Mind if I see the code?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 13th, 2005, 12:12 PM   #4
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
sure, but it seems you're right anyway. just for kicks i changed it from variant to string again and it still works, so i have no idea why it wasn't working to begin with.

this much is declared in a module:
Public SelectedFiles() As String
Public ArrayKw(7) As Variant 'Parent array in question
    Public TempArray() As String 'For feeding to the parent array
Public Skw(7) As String
Public OutputArray() As String

this is the relevant part of the rest of the code; kw is a listbox part of a control array:
<program does some stuff>
ReDim TempArray(0 To kw(index).ListCount) As String
For x = 0 To kw(index).ListCount
    Let TempArray(x) = kw(index).List(x)
Next x
Let ArrayKw(index) = TempArray()
chepfaust is offline   Reply With Quote
Old Mar 13th, 2005, 2:30 PM   #5
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
hah ok i managed to reproduce the error again. when arrayKw(7) is dimmed as string (as you say) and the program is run, i get an "error: type mismatch", and "temparray()" in the last line <let arrayKw(index) = temparray()> is highlighted as being the source of the error.
chepfaust is offline   Reply With Quote
Old Mar 14th, 2005, 2:09 PM   #6
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Yeah, you're trying to store an array of strings inside a single string. The way to do it without using a variant would seem to be Public MyArrayOfStrings() as String() which won't actually work. Why not use a UDT or a two dimensional array i.e. MyStrings(x,y) ? Nested arrays are famous for memory leaks.
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:57 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC