473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VBA doesn't recognize @ sign

Hi Everybody

Is there any way to write a piece of code
something like this:

If Me.txtFrom = Like ""[@*]*""" then
do this
End if

If Me.txtFrom <> Like ""[@*]*""" then
do that
End if

The @ sign is a forbidden symbol

The idea is to trap where a user may not have entered a correct Email
address.

Thanks to all

Smiley Bob

Nov 13 '05 #1
4 1450
Bob,

Try this instead:

If InStr([EmailAddress],"@") = 0 Then
MsgBox "Invalid Email Address"
End If

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Bob Dydd" <sm*******@hotmail.com> wrote in message
news:9f********************************@4ax.com...
Hi Everybody

Is there any way to write a piece of code
something like this:

If Me.txtFrom = Like ""[@*]*""" then
do this
End if

If Me.txtFrom <> Like ""[@*]*""" then
do that
End if

The @ sign is a forbidden symbol

The idea is to trap where a user may not have entered a correct Email
address.

Thanks to all

Smiley Bob

Nov 13 '05 #2
Hi

Thanks for that.

It traps that error elegantly

Bob

On Wed, 21 Jul 2004 13:56:19 GMT, "PC Datasheet" <no****@nospam.spam>
wrote:
Bob,

Try this instead:

If InStr([EmailAddress],"@") = 0 Then
MsgBox "Invalid Email Address"
End If


Nov 13 '05 #3
Bob Dydd <sm*******@hotmail.com> wrote in
news:9f********************************@4ax.com:
Hi Everybody

Is there any way to write a piece of code
something like this:

If Me.txtFrom = Like ""[@*]*""" then
do this
End if

If Me.txtFrom <> Like ""[@*]*""" then
do that
End if

The @ sign is a forbidden symbol

The idea is to trap where a user may not have entered a correct Email
address.

Thanks to all

Smiley Bob


Or, add a reference to Microsoft VB Script Regular Expressions 5.5 (if you
have Win2K or XP, not a problem, otherwise, you need to download the
Windows Scripting Host stuff from Microsoft).

Public Function Find(target As String, source As String) As String
Dim rexp As New RegExp
Dim rxMatches As MatchCollection
Dim rxMatch As Match

rexp.Pattern = target
Set rxMatches = rexp.Execute(source)
For Each rxMatch In rxMatches
Debug.Print rxMatch.Value
Next rxMatch

End Function
Nov 13 '05 #4
Bob Dydd <sm*******@hotmail.com> wrote in
news:9f********************************@4ax.com:
Hi Everybody

Is there any way to write a piece of code
something like this:

If Me.txtFrom = Like ""[@*]*""" then
do this
End if

If Me.txtFrom <> Like ""[@*]*""" then
do that
End if

The @ sign is a forbidden symbol

The idea is to trap where a user may not have entered a
correct Email address.

Thanks to all

Smiley Bob

If nobody has answered you yet, the right way to write the code you
want is If Me.txtFrom Like "*@*" then
and If Me.txtFrom NOT Like "*@*" then
--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lawrence | last post by:
I've a template with some PHP code in it. I need to get the names of all the PHP commands, so I can import them and so I can make sure they are officially allowed (for security purposes, users are...
5
by: geskerrett | last post by:
We are working on a project to decipher a record structure of an old accounting system that originates from the late80's mid-90's. We have come across a number format that appears to be a "float"...
8
by: pacs34 | last post by:
I just read some stuff about XHTML 2.0 and it sounds fascinating so I have been trying to create a small test doc which has a few graphics files but whenever I submit it to the W3 validator I get...
149
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? --...
4
by: Ptaku25 | last post by:
How to catch whole line in the PDF document using javascript? or How to recognize/catch whitespace signs (e.g. "\n" ) in PDF document Which method I should use? Or any other possibility are ? ...
7
by: sonnystarks | last post by:
Page construction in progress: http://www.sdisplay.info/test/ Firefox does not recognize background image referred to on styles.css IE sees it with no problem. What is the problem? Thanx,
26
by: Hazza | last post by:
Hello, I am teaching myself java and am completely stuck. I am using the java development kit and vista command prompt to compile and interpret programmes. I am getting error codes which don't make...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.