by Vincenzo De Luca (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 3rd August 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Find email in a string
On Error GoTo err_de
Dim X, Y As Integer
Dim Dimension As Integer
Dim Indice As Integer
For X = 1 To Len(Inp)
Select Case Mid(Inp, X, 1)
Case Is = " "
Dimension = Dimension + 1
End Select
Next X
ReDim strEmail(Dimension + 1) As String
Indice = 1
For X = 1 To Len(Inp)
Select Case Mid(Inp, X, 1)
Case Is <> " "
strEmail(Indice) = strEmail(Indice) + Mid(Inp, X, 1)
Case Is = " "
Indice = Indice + 1
End Select
Next X
For X = 1 To Dimension + 1
For Y = 1 To Len(strEmail(X))
Select Case Mid(strEmail(X), Y, 1)
Case Is = "@"
GetEmail = strEmail(X)
Case Else
End Select
Next Y
Next X
Exit Function
err_de:
MsgBox (err.DESCRIPTION)
End Function