In this post, I would to show you how to check string whether if a Digit Numebr, Hexadecimal Numbers or Letters. I use 3 difference Textboxes using TextChanged_Event as below:
3. TextboxLetter: for check the string input whether a Letter(A-Z).
1. TextboxDigit: for check the string input whether a Digit Number(1-9) or not.
Private Sub TextBoxDigit_TextChanged(sender As Object, e As EventArgs) Handles TextBoxDigit.TextChanged
Try
If Char.IsDigit(TextBoxDigit.Text.Chars(TextBoxDigit.TextLength - 1)) = True Then
Else
MsgBox("Only Digits Number are allowed to input!")
End If
Catch ex As Exception
End Try
End Sub
2. TextboxNumber: for check the string input whether a Hexadecimal Number(1-9, A-F) o or not.
Private Sub TextBoxNumber_TextChanged(sender As Object, e As EventArgs) Handles TextBoxNumber.TextChanged
Try
If Char.IsNumber(TextBoxNumber.Text.Chars(TextBoxNumber.TextLength - 1)) = True Then
Else
MsgBox("Only Hexadecimal Numbers are allowed to input!")
End If
Catch ex As Exception
End Try
End Sub
Private Sub TextBoxLetter_TextChanged(sender As Object, e As EventArgs) Handles TextBoxLetter.TextChanged
Try
If Char.IsLetter(TextBoxLetter.Text.Chars(TextBoxNumber.TextLength - 1)) = True Then
Else
MsgBox("Only Letters are allowed to input!")
End If
Catch ex As Exception
End Try
End Sub
0 comments:
Post a Comment