![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
split() function error - type mismatch
For x = 0 To 4
Let SubArray = Split(GenericTextBox(x).Text, vbCrLf)
Let MainArray(x) = SubArray()
Next xi have five text boxes in a control array (generictextbox) and each textbox contains a lot of individual lines of text, formatted like apples bananas carrots rutebaga so i'm trying to use the split function using a line break as the delimiter to break down all the entries and store each line into an array (subarray) so i can store that whole array into a parent array (mainarray). every time i execute this code though i get an 'error 13: type mismatch.' the bolded text is highlighted. subarray and mainarray have both been declared as variant arrays. any ideas? thanks Last edited by chepfaust; Apr 6th, 2005 at 2:52 PM. |
|
|
|
|
|
#2 |
|
Expert Programmer
|
Right, for starters you haven't had to use "Let" since GWBASIC. Also Make sure that SubArray is declared as an array of strings, as that is what split returns. Generally, nesting arrays doesn't seem to be a good idea with VB, as you lose the security of typecasting for starters: using double index notation MyArray(x,y) As String would work and wouldn't need to be defined as a variant.
Another consideration is that you can't assign to arrays that already contain data: you would need to somehow "destroy" the array (i.e. set it back to its previous undimmed state before calling redim) but this doesn't seem to be possible! Last edited by Rory; Apr 6th, 2005 at 4:36 PM. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
thanks for the pointers, i did get the function working but then i revised my entire process to not even deal with parent/sub arrays. it still works, and i'm still grateful to you
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|