The split function changes a string array to a variant array - which means if you later redim preserve what you thought was a string array you lose all your data.
Code: Select all
SUB MAIN
DIM ST AS STRING,STS() AS STRING
st= "A" & Chr(0) & "N" & Chr(0) & "D"
msgbox vartype(sts) '8200 = 8192 for array + 8 for string
sts= split(st,chr(0))
msgbox vartype(sts) '8200 = 8192 for array + 12 for VARIANT
for i = 0 to UBOUND(STS)
msgbox sts(i)
next
redim preserve sts(2)
msgbox vartype(sts) '8200 = 8192 for array + 8 for string BUT DATA IS LOST
for i = 0 to UBOUND(STS)
msgbox sts(i)
next
END SUB
http://www.vb-helper.com/howto_vb5_split_join.html
Its 1 based though. You'll have to modify it slightly to be zero based (putting num_items = -1 before the loop and
ReDim Preserve result(num_items) inside it)