helo every one!

how can i split string in vb 6??? i got some string in list box which looks like this

item1 4 4.50
item2 2 4.00
item3 5 10.00

now i want to split that line into 3 different string.
any help will b appreciate . thx

Dim MyArray() As String
MyArray = Split(List1.List(1), " ") 'or if tab seperated vbTab instead of " "

Good Luck

thank you for your reply. but i got problem. i have tried this. for example if i have item in the list box which has got different whitespace...
item1 5 4.5
item2 4 2.00
some thing like this, so there is no fix whitespace in between. hope i explained properly.

Not really, I see no differenct between item 1 and 2. However, if split does not work for you and your example is an actual representation of your data, then you could use the Left Function, Mid Function, Trim Function, Right Function, and (etc. on string functions) to pull it apart manually.

Good Luck

s="1   2 3 4      5 6"
s=replace(s,"  "," ")   'Replace 2 Space to 1 space
dim v as variant
v=split(s," ")
'v(0)=1
'v(1)=2
'v(2)=3
'v(3)=4
'v(4)=5
'v(5)=6
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.