Solved

Text Manipulation

Posted on 2003-12-09
3
294 Views
Last Modified: 2010-05-03
I have some email address's ...

xys@sdsd.43fdg.net
wetb256@hotmail.com
(made up for example)

I want to b able to check of the email addess contains "@hotmail.com" or what ever I decide.

if it doesn't contain What I want to check for I want to remove all text before the @ symbol.

So "xys@sdsd.43fdg.net" would become "@sdsd.43fdg.net"
0
Comment
Question by:Terry Rogers
3 Comments
 
LVL 5

Expert Comment

by:mccainz2
ID: 9907982
Private Sub Command1_Click()
    semail = "xys@sdsd.43fdg.net"
    istart = InStr(1, semail, "@sdsd.43fdg.net")
    If istart > 0 Then
        MsgBox Mid(semail, istart)
    End If
End Sub
0
 
LVL 4

Expert Comment

by:dasari
ID: 9908019
   Dim strEmail As String
   
    strEmail = "xxx@hotmail.com"
    If InStr(1, strEmail, "@hotmail.com", vbTextCompare) <= 0 Then
           strEmail = Mid(strEmail, InStr(1, strEmail, "@", vbTextCompare), Len(strEmail) - InStr(1, strEmail, "@hotmail.com", vbTextCompare))
    End If
    MsgBox strEmail
   
    strEmail = "xxx@yahoo.com"
    If InStr(1, strEmail, "@hotmail.com", vbTextCompare) <= 0 Then
           strEmail = Mid(strEmail, InStr(1, strEmail, "@", vbTextCompare), Len(strEmail) - InStr(1, strEmail, "@hotmail.com", vbTextCompare))
    End If
    MsgBox strEmail
0
 
LVL 3

Accepted Solution

by:
ToolMan earned 35 total points
ID: 9908158
Hi

there are alot of ways to get done what you want........... like here -->

Dim emailAdd(50) As String

emailAdd(0) = "xys@sdsd.43fdg.net"
emailAdd(1) = "wetb256@hotmail.com"
emailAdd(2) = "@ytsascs.com"
emailAdd(3) = ""


For i = 0 To UBound(emailAdd)
    splittedAdd = Split(emailAdd(i), "@")
    If UBound(splittedAdd) > 0 Then
        username = splittedAdd(0)
        domain = "@" & splittedAdd(1)
        Debug.Print "Domain: " & domain
        Debug.Print "username: " & username
    Else
        Debug.Print emailAdd(i) & " is invalid."
    End If
Next
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Passing a Text Box name to a Sub 6 99
MsgBox 4 69
IF ELSE Statement in Excel Macro VBA 16 75
Automatic Email Reminder 4 58
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question