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

Left & right

Status
Not open for further replies.

Kendel

Programmer
Apr 24, 2002
1,512
US
Hi All:

How do I seperate the left & right of the string? My string looks like this:

<%Str1, Str2%>

I don't know the lenght of Str1 or Str2.

Thanks.
 
Code:
YourString = "<%Str1, Str2%>"

strLeft = Left(YourString, InStr(1, YourString, ",", 1) - 1)
strRight = Mid(YourString, InStr(1, YourString, ",", 1) + 1, Len(YourString))
 
You could also use the Split() function to create an array from the string, with the comma as the delimitter.

That is probably overkill for just 2 values but for 3 or more it is a good idea.
 
Thank you guys. Both solutions work for me but I'm uisng rjoubert's. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top