IT KNOWLEDGE

IT KNOWLEDGE
BC

Wednesday, May 21, 2014

Check String (Digit Number, Hexadecimal Numbers and Letter)

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:


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


3.     TextboxLetter:     for check the string input whether a Letter(A-Z).

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






Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: itech-9999

0 comments: