VB.Net validation

Status
Not open for further replies.

97lt2959

In Runtime
Messages
169
Hi,

I'm having a problem in VB .Net.

I have a series of text boxes and combo boxes on a form.

I need to check that user has entered something in each field.

I have no idea how to go about this other than using the IF statement however with 18 boxes is a lot of nested if statements.

Is there any other way I can go about it?

Thanks,

Lee
 
Im assuming you have 18 text boxes and need to validate it. If so, this is the code for it.

Lets say you have text1 - text18.

For i = 1 to 18
If texti.text = "" then
Msgbox("Error! Field not Filled")
End if
Next

5 Lines for 18 boxes :D

But if you have names for the textboxes, it gets more complicated o_O

Have a button called "Submit" or something, and This should be its coding -


If txtname1.text <> "" and txtname2.text <> "" and .................. and txtname18.text <> "" Then
(Put in whatever should happen, like the combo boxes get enabled, etc")
End If


Hope this helps o_O
 
Status
Not open for further replies.
Back
Top Bottom