Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Apr 6th, 2005, 2:50 PM   #1
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
split() function error - type mismatch

For x = 0 To 4
    Let SubArray = Split(GenericTextBox(x).Text, vbCrLf)
    Let MainArray(x) = SubArray()
Next x

i 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.
chepfaust is offline   Reply With Quote
Old Apr 6th, 2005, 4:29 PM   #2
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
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.
Rory is offline   Reply With Quote
Old Apr 6th, 2005, 11:55 PM   #3
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
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
chepfaust 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 5:13 AM.

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