I am using the split function to split a string.
I have an array equal to the function to catch the substrings.
When I run the program, I get an error:
"Can't assign to array"
Could someone just post a couple lines of VB 6 code to show me how
this works?
Thanks.
Rick Rothstein - 29 Jan 2005 00:33 GMT
> I am using the split function to split a string.
>
[quoted text clipped - 6 lines]
> Could someone just post a couple lines of VB 6 code to show me how
> this works?
Dim StringToSplit As String
Dim MyArray() As String
StringToSplit = "Zero,One,Two,Three,Four,Five"
MyArray = Split(StringToSplit, ",")
MyArray now has "Zero" at element 0, "One" at element 1, "Two" at
element 2, etc.
Rick - MVP
Jim Edgar - 29 Jan 2005 00:36 GMT
> I am using the split function to split a string.
>
[quoted text clipped - 8 lines]
>
> Thanks.
Be sure to use an undimensioned array.
Dim s() As String
Dim str As String
Dim i As Integer
str = "This,is,a,test,."
s = Split(str, ",")
For i = LBound(s) To UBound(s)
Debug.Print s(i)
Next
Jim Edgar
Randy Birch - 29 Jan 2005 00:40 GMT
Don't set the size of the array to receive the return value from Split -
Split will take care of dimensioning it correctly ...
dim a(0 to 3) as string ' wrong
dim a() as string 'right
a()=split(whatever, somedelimiter)

Signature
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
:I am using the split function to split a string.
:
[quoted text clipped - 8 lines]
:
: Thanks.
Compu-Pikachu - 29 Jan 2005 06:20 GMT
[FRED LUGAR] I am using the Split function to split a string. I have an
array equal to the function to catch the substrings. When I run the
program, I get an error, "Can't assign to array."
Could someone just post a couple lines of VB6 code to show me how this
works?
[HOSHI PATRICIA FRIEDMAN] Boy, I wish I HAD the Split keyword, because I'm
only using VB4, so I can't help you. You could check out your
documentation, though.
Karl E. Peterson - 31 Jan 2005 20:24 GMT
> [HOSHI PATRICIA FRIEDMAN] Boy, I wish I HAD the Split keyword,
> because I'm only using VB4, so I can't help you.
Roll yer own, Hoshi... http://www.xbeat.net/vbspeed/c_Split.htm

Signature
[Microsoft Basic: 1976-2001, RIP]