Data Validation in textboxes

tqmd1

Well-known member
Joined
Dec 5, 2009
Messages
60
Programming Experience
Beginner
Dear Experts

I Have four textboxes,

I want textbox1 to accept only char data.
I want textbox2 to accept only numeric data.
I want textbox3 to accept only alphanumeric data.
I want textbox4 to accept only bolean data.

Please help
 
VB.NET:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
'numbers only
If e.KeyChar.IsNumber(e.KeyChar) = False Then
    e.Handled = True
End If
End Sub
VB.NET:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
'Text only
If e.KeyChar.IsNumber(e.KeyChar) = True Then
    e.Handled = True
End If
End Sub
Alphanumeric only? What other options are there?

I have no idea what you mean by Boolean Data - do you means allow only the words True or False?
 
Back
Top