AndyK
February 20th, 2000, 11:11 AM
How to check if string is in e-mail format and if it's not then text1 = "" when text1 lost focus
|
Click to See Complete Forum and Search --> : Format text AndyK February 20th, 2000, 11:11 AM How to check if string is in e-mail format and if it's not then text1 = "" when text1 lost focus Cakkie February 20th, 2000, 11:46 PM Add folowing code to your form: private sub text1_lostfocus() dim intPos as string dim isEmail as boolean isEmail = false 'check for @ in text1 and get its position intpos = instr(text1.text,"@") if intpos > 0 then ' if there is a @ in the text if instr(intPos,text1.text,".") > 0 then 'if there is a . after the @ isEmail = true end if end if if not(isEmail) then ' if not a valid email text1.text = "" end if End sub Tom Cannaerts slisse@planetinternet.be The best way to escape a problem, is to solve it. Chris Eastwood February 21st, 2000, 05:33 AM An even easier way : If Text1.Text Like "*@*.*" then MsgBox "OK" else MsgBox "not ok" End If - I must remember to start using the Like command more often! Chris Eastwood CodeGuru - the website for developers http://codeguru.developer.com/vb Cakkie February 21st, 2000, 05:52 AM me 2 Tom Cannaerts slisse@planetinternet.be The best way to escape a problem, is to solve it. AndyK February 21st, 2000, 01:55 PM LIKE rocks!!! :-) codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |