?
Solved

Text Manipulation

Posted on 2003-12-09
3
Medium Priority
?
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 70 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Suggested Courses

719 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