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.
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.
Code:
If InStr(1,[ShopEmailAddress],"@")<>0 Then
MsgBox "Thanks for that email address."
Else
MsgBox "That's not a valid email address."
End If