Solved

Text Manipulation

Posted on 2003-12-09
3
293 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

770 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