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

crop string

Status
Not open for further replies.

M626

Programmer
Mar 13, 2002
299
How can i crop a string so i remove everything after the "@" sign. For example say i want to take a string "AAA@INTERNET" and remove everhing from the @ so my new string is AAA?
 
Hello

A way i think of dealing with this is by a loop function. Take the string and loop by each character until @ appears.

I can try and sort out some coding if you get stuck.
 
Use the InStr function to find the position of @, then use Left to get the first x characters from the string.
For example:
Left("AAA@INTERNET",InStr("AAA@INTERNET","@")-1)
 
n = InStr(mystring, "@")
newstring = Right(mystring, Len(mystring) - n)
MsgBox newstring

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Or just be lazy... (Great if you've got a lot of addresses to parse)

Code:
    Dim email() As String
    email = Split("me@here.com", "@")
    MsgBox email(0) ' or whatever....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top