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

instr to find host name in an email address 2

Status
Not open for further replies.

RMcCallan

Programmer
Sep 20, 2010
62
GB
Basically I've written the simple code for finding the position of the @ symbol in an email address but what I want to do now is take what is to the right of this (if possible just taking the host name, not the .com/.co.uk) Does anybody know how to do this? Everything I have found has just said how to either find positions or find the first/last specified characters... Any replies appreciated.

Thanks,
Rebecca
 
A starting point:
strDomain = Mid(strEmail, 1 + InStr(strEmail, "@"))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Furthermore:
strHost = Split(Mid(strEmail, 1 + InStr(strEmail, "@")), ".")(0)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya RMcCallan . . .

Try:
Code:
[blue]   Public Function Domain(Address As String) As String
   Dim idx As Long
   
   idx = InStr(1, Address, "@")
   
   If idx <> 0 Then
      Domain = Right(Address, Len(Address) - idx)
   Else
      MsgBox "Not an e-mail address!"
   End If
      
End Function[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Sorry I have actually dont it myself now but thank you for your help, my solution was similar to the ones you guys came up with.

Thanks,
Rebecca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top