[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

I need help parsing a string in VB6

Posted on 2013-11-15
5
Medium Priority
?
336 Views
Last Modified: 2013-12-04
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
0
Comment
Question by:mainrotor
  • 3
  • 2
5 Comments
 
LVL 50

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 39651637
strVar2 = Split(strVar1,",";")(0)
strVar3 = Split(strVar1,",";")(1)
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39651642
It would be easier to use an array and the Split function:
Dim strVars() as string
strVars = Split("THIS;ROCKS", ";")

Open in new window

0
 
LVL 50

Expert Comment

by:Martin Liss
ID: 39651646
My code was wrong it should be
strVar2 = Split(strVar1,";")(0)
strVar3 = Split(strVar1,";")(1)
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39651648
But if you have a limited number of elements it's not easier than Martin's recommendation
0
 
LVL 50

Expert Comment

by:Martin Liss
ID: 39670784
Did any of the above help you?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question