Link to home
Start Free TrialLog in
Avatar of mainrotor
mainrotor

asked on

I need help parsing a string in VB6

Hi Experts,
I have a string in my VB6 application, which holds two values separated by a semi-colon.  I want to parse the string and put the values into separate strings.  How can I do that?


Example of what I want to accomplish

Dim strVar1 as string
Dim strVar2 as string
Dim strVar3 as string

strVar1 = "THIS;ROCKS"


I want to parse strVar1 and put each of the values separated by the semi-colon into the other two string variables:
strVar2 = "THIS"
strVar3 = "ROCKS"


Thanks in advance,
mrotor
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It would be easier to use an array and the Split function:
Dim strVars() as string
strVars = Split("THIS;ROCKS", ";")

Open in new window

My code was wrong it should be
strVar2 = Split(strVar1,";")(0)
strVar3 = Split(strVar1,";")(1)
But if you have a limited number of elements it's not easier than Martin's recommendation
Did any of the above help you?