|
-
Mar 26th, 2005, 07:14 AM
#1
Thread Starter
Lively Member
Find an email address in a string
I've go a string holding a company name, address, email address, phone and fax number.
e.g. string="Quadrant Subscription Services Rockwood House Perrymount Road Haywards Heath E-mail: [email protected] Telephone: +44 (0) 1444 445517 Fax: +44 (0) 1444 445526"
How can I find the email address and put a <B> tag in front of it and a </B> tag at the end?
like this: <B>[email protected]</B>
Thanks
Kati
-
Mar 26th, 2005, 07:28 AM
#2
Need-a-life Member
Re: Find an email address in a string
Try:
VB Code:
Dim s As String
Dim iEmail As Integer
Dim iEndEmail As Integer
s = "Quadrant Subscription Services Rockwood House Perrymount Road Haywards Heath E-mail: " & _
iEmail = InStr(1, s, "E-mail:", vbTextCompare)
If iEmail Then
iEndEmail = InStr(iEmail + 8, s, " ")
If iEndEmail > iEmail Then
s = Left$(s, iEmail + 7) & "<B>" & Mid$(s, iEmail + 8, iEndEmail - iEmail - 8) & _
"</B>" & Mid$(s, iEndEmail)
End If
End If
Debug.Print s
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Mar 26th, 2005, 07:48 AM
#3
Thread Starter
Lively Member
Re: Find an email address in a string
Thanks for you reply.
The problem is that I can't rely on the string containing "E-mail:", so I will have to find the "@" symbol somehow and then find the beginning and the end of that string.
Any ideas?
Thanks
Kati
-
Mar 26th, 2005, 07:53 AM
#4
Need-a-life Member
Re: Find an email address in a string
 Originally Posted by katib
Thanks for you reply.
The problem is that I can't rely on the string containing "E-mail:", so I will have to find the "@" symbol somehow and then find the beginning and the end of that string.
Any ideas?
Thanks
Kati
Try...
VB Code:
Dim s As String
Dim iAt As Integer
Dim iEndEmail As Integer
Dim iStartEmail As Integer
s = "Quadrant Subscription Services Rockwood House Perrymount Road Haywards Heath E-mail: " & _
iAt = InStr(1, s, "@")
If iAt Then
iStartEmail = InStrRev(Left$(s, iAt), " ")
If iStartEmail Then
iEndEmail = InStr(iAt, s, " ")
If iEndEmail > iStartEmail Then
s = Left$(s, iStartEmail) & "<B>" & Mid$(s, iStartEmail + 1, _
iEndEmail - iStartEmail - 1) & "</B>" & Mid$(s, iEndEmail)
End If
End If
End If
Debug.Print s
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Mar 26th, 2005, 08:02 AM
#5
Thread Starter
Lively Member
Re: Find an email address in a string
Thanks a lot! That worked well.
Kati
-
Mar 26th, 2005, 08:09 AM
#6
Need-a-life Member
Re: Find an email address in a string
 Originally Posted by katib
Thanks a lot! That worked well.
Kati
You might want to add "[Resolved]" in the post's subject and/or rate the post.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|