Solved

Text Manipulation

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now