Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I split a sting into two different variables

Status
Not open for further replies.

jpower69

Programmer
Feb 5, 2008
54
0
0
US
I have a console application that I am calling from a vfp program
the vfp rpogram is apssing two variables to the console applicaiotn

the following statement is being used in console appl. to accept the variables being passed from the vfp applicaiton
wpassword = Trim(Environment.GetCommandLineArgs(1))

the variable wpassword contains the two field separated by a comma','
for example wpassword = "JIMNAN,402679"

how can i get set the value of one variable = 'jimnan' and another variable = '402679'
the first variable can have a max. length of 7 character and the second variable can have a max. length of ten characters

I have wpassword.substring(0,6) which give me 'jimnan' but I can not figure out how to get the second variable to the right on the comma','

any suggestions/comments greatly appreciated

thanks in advance















 
Please dis-regard this post...

found the statements that does what I need

thanks again
 
How about:

Code:
Dim wpassword As String = "JIMNAN,402679"
Dim intComma As Integer
[green]
'Where is a comma?[/green]
intComma = Strings.InStr(wpassword, ",")

If intComma > 0 Then[green]
    'we do have a comma[/green]
    MsgBox(Strings.Left(wpassword, intComma - 1))
    MsgBox(Strings.Mid(wpassword, intComma + 1))[green]
   'or[/green]
    MsgBox(Strings.Split(wpassword, ",")(0))
    MsgBox(Strings.Split(wpassword, ",")(1))
End If

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
thanks for the reply

i'll try that..

this is what I just tried
wpassword = Trim(Environment.GetCommandLineArgs(1))

i = wpassword.IndexOf(",")

mpassword = Left(wpassword, i)
i = i - 1
mpassval1 = Right(wpassword, i)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top