|
Question : Checking Alphanumeric Character
|
|
Is there any function in VB.Net with which you can check if a string is alphanumeric or not? I mean which will return false if there is any character other than alphabets or numbers?
|
|
Answer : Checking Alphanumeric Character
|
|
You can write your own function. Here is one approach:
Private Function isAlphaNumeric(ByVal strInput As String) As Boolean Dim validChars As String = "abcdefghijklmnopqrstuvwxyz1234567890" Dim i As Integer For i = 0 To strInput.Length - 1 If validChars.IndexOf(strInput.Substring(i, 1)) = -1 Then Return False End If Next Return True End Function
|
|
|