Option Explicit
Private Sub Form_Click()
Dim sTarget As String
sTarget = " 123 abc [EMAIL PROTECTED] def ghi "
Print sTarget
Print " " & ReturnEmailAddress(sTarget)
sTarget = "[EMAIL PROTECTED]"
Print sTarget
Print " " & ReturnEmailAddress(sTarget)
sTarget = " 123 no email address in here "
Print sTarget
Print " " & ReturnEmailAddress(sTarget)
End Sub
Private Function ReturnEmailAddress(ByVal sIN As String) As String
Dim myArr() As String
Dim i As Integer
Dim sWork As String
Dim sReturn As String
sIN = Trim(sIN)
If InStr(sIN, " ") = 0 Then
'Means there are no spaces present
If InStr(sIN, "@") = 0 Then
'There is no email address present, so return nothing
Else
'It must be just an eamil address (no other words in the line)
sReturn = sIN
End If
Else
'Means there are spaces presnt, so Split using space as delim
myArr = Split(sIN, " ")
For i = 0 To UBound(myArr)
If InStr(myArr(i), "@") > 0 Then
'We have found the email address
sReturn = myArr(i)
End If
Next i
End If
ReturnEmailAddress = sReturn
End Function
Hope this Helps,
Rob
--- In [email protected], "sitlani_vijay" <[EMAIL PROTECTED]> wrote:
> Hi Friends
>
> I will appriciate if any one of you can help me in searching "Email
> address in Text file through VB".
>
> I have got the line where '@' symbol is available.
>
> Regards
> Vijay
'// =======================================================
Rules : http://ReliableAnswers.com/List/Rules.asp
Home : http://groups.yahoo.com/group/vbHelp/
=======================================================
Post : [email protected]
Join : [EMAIL PROTECTED]
Leave : [EMAIL PROTECTED]
'// =======================================================
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/vbhelp/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/