View Full Version : Explanation of code


wildexodus
04-02-2003, 06:52 AM
Could someone please explain to me what this code does. It works, theres nothing wrong with it, i would just like to understand what it means so i can adapt it in the future.

Mile-O
04-02-2003, 06:53 AM
Hmmm, by looking at the code I'd guess that it does nothing! :rolleyes:

Can you post it?

wildexodus
04-02-2003, 06:57 AM
Sorry, im so daft, can't believe i did that!

InStr(1,[ShopEmailAddress],"@")<>0

Mile-O
04-02-2003, 07:06 AM
What it does is looks in your string/control/etc. to find if it contains the @ symbol which valuidates that it will be an email address.

So, basically, looking at each component.

InStr() - the In String function

1 - the position in the text to start looking for the required string, so we are looking at the text from the start (i.e first character)

ShopEmailAddress - the name of the field/control that we are performing the InStr() function upon

@ The text that we are searching for within ShopEmailAddress

If the text is found within the string then InStr() returns the first instance of the text within the searched text and this is the character's position - if it is not found, a 0 is returned.

If I were to look for a hyphen in my screenname Mile-O-Phile then the InStr() function would return 5 as the first hyphen in my name is the fifth character

So, what your expression is doing is evaluating some text to determine whether it contains a specified string and returns a number and acting upon the find as evidenced by the <>0 at the end.

If InStr(1,[ShopEmailAddress],"@")<>0 Then
MsgBox "Thanks for that email address."
Else
MsgBox "That's not a valid email address."
End If

That enough for you? :p

wildexodus
04-02-2003, 07:12 AM
great thankyou