-
String to array
Hi !!!
Can someone help me to resolve this little problem ?
I got a string like:
Test = "alpha|beta|gamma;alpha1|beta1|gamma1;alpha2|beta2|gamma2;alpha3|beta3|gamma3;"
And I'like it to be in a two dimension array like:
arr=
alpha beta gamma
alpha1 beta1 gamma1
alpha2 beta2 gamma2
alpha3 beta3 gamma3
How can i easily do that ??
Thanks for your help...
-
Re: String to array
Well, there's no way to do that in one time, but we can do it like this:
private Sub Command1_Click()
Dim test as string
test = "alpha|beta|gamma;alpha1|beta1|gamma1;alpha2|beta2|gamma2;alpha3|beta3|gamma3;"
Dim tmpArr
Dim tmpArr2
Dim RealArr()
tmpArr = Split(test, ";")
ReDim RealArr(UBound(tmpArr), 3)
for t = 0 to UBound(tmpArr) - 1
tmpArr2 = Split(tmpArr(t), "|")
If Not (IsEmpty(tmpArr2)) then
for r = 0 to 2
RealArr(t, r) = tmpArr2(r)
next r
End If
next t
for t = 0 to UBound(RealArr)
Debug.print RealArr(t, 0) & " " & RealArr(t, 1) & " " & RealArr(t, 2)
next t
End Sub
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
-
Re: String to array
Thx a lot for your Help!!!!!!!
Pierre-jean