![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
That's odd... it should work fine with strings too. Mind if I see the code?
|
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
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 Stringthis 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() |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
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.
|
|
|
|
|
|
#6 |
|
Expert Programmer
|
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.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|