How to chunk the country codes in e-mail address ?

Thursday, April 9, 2009

This script used to remove the country codes from the e-mail address. In this sample, NORMAN.MARTENA@UK.PQRSTUV.COM will be translated to NORMAN.MARTENA@PQRSTUV.COM.
What if I need to replace the PQRSTUV with ABC?. .
Another loop of Mid$ to add in I guess..


Dim a As String

strEmailLong = "NORMAN.MARTENA@UK.PQRSTUV.COM"

position = Len ( strEmailLong )

For k = 1 To position
subString1$ = Mid$ ( strEmailLong, k, 1)

If subString1$ = "@" Then
subString2$ = Mid$ ( strEmailLong, (k + 3), 1 )

If subString2$ = "." Then
subString3$ = Mid$ ( strEmailLong, 1, k)
subString4$ = Mid$ ( strEmailLong, ( k + 4))

strEmailShort$ = subString3$ + subString4$
Else
strEmailShort$ = ""
End If

Exit For

End If
'k = k + 1
Next

If strEmailShort$ = "" Then
a = strEmailLong
Else
a = strEmailShort$
End If

End Sub

2 comments:

Benedict Bernard said...

aiyooo cakap bahasa jawa iols tak paham..kekekeke..

SiMpleSmArtErMe said...

Ben nih bukan bahasa jawa la..nih bahasa domino tp bukan domino pizza hokayy..