Results 1 to 4 of 4

Thread: [RESOLVED] String Function Help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Posts
    250

    Resolved [RESOLVED] String Function Help

    Hi All,

    I have a string that I need to extract only a certain part of the data from:

    SMTP:[email protected]

    I need to extrapolate "Mike.Smith" from the above string.

    I have about 1,000 strings like this, the FirstName.LastName will change on each sting.

    How do I parse out the "SMTP:" and the "@abc.com"?

    Thank you all for your help!

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: String Function Help

    There are a number of way but here is one.
    Code:
    Option Explicit
    
    Dim strIn
    Dim strParts
    
    	strIn = "SMTP:[email protected]"
    
    	' Split the string on the ampersand
    	strParts = Split(strIn, "@")
    
    	' You will now have an array that contains
    	' SMTP:Mike.Smith as the first element and
    	' abc.com as the second element
    
    	' Now remove the first 5 characters of the first element
    	strParts(0) = Mid(strParts(0), 6)
    
    	MsgBox strParts(0)

  3. #3
    Addicted Member
    Join Date
    May 2005
    Posts
    137

    Re: String Function Help

    if its always gonna be the same domain bit then you could also

    Code:
    Replace(Replace(EmailAddressHere, "@abc.com", ""), "SMTP:", "")
    that will strip off the domain name and the smtp bit but if there are going to bve different things after the "@" then i would definately go with MarkT's method

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Posts
    250

    Re: String Function Help

    Awesome, thank you guys!

    Your explanations and help is why I love coming to this site. Thank you both very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width