INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How can I split a sting into two different variables

How can I split a sting into two different variables

(OP)
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















RE: How can I split a sting into two different variables

(OP)
Please dis-regard this post...

found the statements that does what I need

thanks again

RE: How can I split a sting into two different variables

How about:

CODE

Dim wpassword As String = "JIMNAN,402679"
Dim intComma As Integer

'Where is a comma?
intComma = Strings.InStr(wpassword, ",")

If intComma > 0 Then
    'we do have a comma
    MsgBox(Strings.Left(wpassword, intComma - 1))
    MsgBox(Strings.Mid(wpassword, intComma + 1))
   'or
    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.

RE: How can I split a sting into two different variables

(OP)
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)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close