Chủ Nhật, 4 tháng 9, 2016

VB.NET Tutorial : Check if String is a Letter, Number, Digit


Vb.NET Tutorial - How we can check if String is a Letter, check if String is a Number, check if String is a Digit in VB.NET? Char.IsNumber() functions is to checks if a string entered is a number (hex 0 - 9 - A - F), Char.IsLetter() checks if a string entered is a letter (a - z), Char.IsDigit() to check a string entered is a digit.

at the previews lessons, we have learned about String Equals() CopyTo() Copy() Contains() and String Length() Insert() IndexOf() function in vb.net

Check if String is a Number (hex 0 - 9 - A - F)

If Char.IsNumber(number.Text.Chars(number.TextLength - 1)) = True Then
 MsgBox("its a Numbers")
Else
 MsgBox("Please insert a Number")
End If

Check if String is a Letters (a-z)

If Char.IsLetter(Letters.Text.Chars(Letters.TextLength - 1)) = True Then
 MsgBox("it's Letters")
Else
 MsgBox("Please enter a Letter")
End If

Check if String is a Letter, Number, Digit

Check if String is a Digit

If Char.IsDigit(Digits.Text.Chars(Digits.TextLength - 1)) = True Then
 MsgBox("its a Digit")
Else
 MsgBox("please enter a Digit")
End If

See you Next Lessons ....

Không có nhận xét nào:

Đăng nhận xét