winforms - VB.NET Multiple Textboxes Validation -


could show guidance(am not asking homework) validating form multiple text boxes? user informed problematic field.

the source of form:

private sub btnnewuser_click(byval sender system.object, byval e system.eventargs) handles btnnewuser.click   'if txtemail.text.contains(" "c) or not(instr(txtemail.text, "@"))   'txtemail.clear()   'elseif txtpassword.text.contains(" "c)   'txtpassword.clear()   'elseif txtpin.text ''#uh     aryuserrecord(0) = txtemail.text     aryuserrecord(1) = txtpassword.text     aryuserrecord(2) = txtpin.text ''#consists of letter 2 numbers                     addnewuser = join(aryuserdata, ",")    ''#more source     me.dialogresult = dialogresult.ok end sub 

you can use errorprovider mark problematic fields. you'll want hook validating event each textbox. this:

private sub textbox1_validating(byval sender system.object, byval e system.componentmodel.canceleventargs) handles textbox1.validating         if textbox1.text = ""             errorprovider1.seterror(textbox1, "text cannot empty")             e.cancel = true         end if end sub 

then when textbox validate, can hook validated event clear out errorprovider:

private sub textbox1_validated(byval sender system.object, byval e system.eventargs) handles textbox1.validated         errorprovider1.seterror(textbox1, "") end sub 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -