IT KNOWLEDGE

IT KNOWLEDGE
BC

Thursday, May 22, 2014

Method to check characters in strings (VB.Net)

Below are all methods for checking characters in strings with sample code.
    Method      Description
  IsDigit   Returns True if the character is a number from 0 - 9
  IsLetter   Returns True if the character is a Letter from A - Z
  IsNumber   Returns True if the character is a hexadecimal number from 0 - F
  IsLetterOrDigit   Returns True if character is a letter or a number
  IsPunctuation   Returns True if character is a punctuation mark.
  IsSymbol   Returns True if character is a symbol
  IsLower   Returns True if character is a lower case letter
  IsUpper   Returns True if character is an upper case letterd

 IsDigit
If Char.IsDigit(TextBoxDigit.Text.Chars(TextBoxDigit.TextLength - 1)) = True Then
            Else
                MsgBox("Only Digits Number are allowed to input!")
End If

 IsLetter
 If Char.IsLetter(TextBoxLetter.Text.Chars(TextBoxLetter.TextLength - 1)) = True Then
            Else
                MsgBox("Only Letters are allowed to input!")
 End If

                                                                            IsNumber
If Char.IsNumber(TextBoxNumber.Text.Chars(TextBoxNumber.TextLength - 1)) = True Then
            Else
                MsgBox("Only Hexi Numbers are allowed to input!")
 End If

 IsLetterOrDigit
 If Char.IsLetterOrDigit(TextBoxLetterOrDegit.Text.Chars(TextBoxLetterOrDegit.TextLength - 1)) = True Then
            Else
                MsgBox("Only Letters or Digits are allowed to input!")
  End If

IsPunctuation
 If Char.IsPunctuation(TextBoxPuntuation.Text.Chars(TextBoxPuntuation.TextLength - 1)) = True Then
            Else
                MsgBox("Only Puntuation are allowed to input!")
  End If

IsSymbol
 If Char.IsSymbol(TextBoxSymbol.Text.Chars(TextBoxSymbol.TextLength - 1)) = True Then
            Else
                MsgBox("Only Symbols are allowed to input!")
 End If

IsLower
 If Char.IsLower(TextBoxLower.Text.Chars(TextBoxLower.TextLength - 1)) = True Then
            Else
                MsgBox("Only Lower Case are allowed to input!")
 End If

 IsUpper
If Char.IsUpper(TextBoxUpper.Text.Chars(TextBoxUpper.TextLength - 1)) = True Then
            Else
                MsgBox("Only Upper Case are allowed to input!")
 End If

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

0 comments: