It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Validating a text box

Moderator: dafunkymunky

Validating a text box

Postby Darren on Wed May 04, 2011 4:51 pm

Hi Sorry I'm back again I need help with the code that will validate my 3 texboxes so that the button will not move to the next form unless all text boxes are filled in
I have seen forms whereby a message appears stating EG Name required etc
Can anyone help Thanks
Darren
 
Posts: 13
Joined: Tue May 03, 2011 12:30 pm

Re: Validating a text box

Postby jblues on Wed May 04, 2011 6:29 pm

First, set the default value of the button as enabled = false.
There are 2 ways to do this, either as code in the form load event or as a proplerty of the button.
The code is simply
btnX.Enabled = False
Then on the text change event of each textbox, change the value to true if your conditions are met.
Something like this

Private Sub richfield1_textChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles richfield1_textChanged, _
richfield2_textChanged, _
richfield3_textChanged
If (richfield1_textChanged = "" Or richfield2_textChanged = "") _
btnX.Enabled = True
End If

Good Luck!
jblues
 
Posts: 13
Joined: Tue May 03, 2011 11:08 am

Re: Validating a text box

Postby Darren on Thu May 05, 2011 5:31 am

jblues,
You have come up trumps again with the answer Once again many thanks appreciate your help Regards
Darren
 
Posts: 13
Joined: Tue May 03, 2011 12:30 pm


Who is online

Users browsing this forum: No registered users and 2 guests