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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Place everything before --- into a variable

Status
Not open for further replies.

jasonhuibers

Programmer
Sep 12, 2005
290
CA
Charlie/Sam/Mike---Lee/Ho/Chu

How can I take everything before '---' and store into a variable
and everything after '---' into a second variable?

First Name: Charlie/Sam/Mike Last Name: Lee/Ho/Chu

 
A starting point:
Code:
yourString="Charlie/Sam/Mike---Lee/Ho/Chu"
FirstName=Left(yourString,InStr(yourString,"---")-1)
LastName=Mid(yourString,InStr(yourString,"---")+3)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Another option, assuming there is always a "---" in the string:
Code:
yourString="Charlie/Sam/Mike---Lee/Ho/Chu"
arrName = Split(yourString, "---")
FirstName=arrName(0)
LastName=arrName(1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top