CodeItBetter Programming Another VB Programming Blog

How to check if a string contains only Alpha Numeric Characters

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'String Manipulation - How to check if a string contains only Alpha Numeric Characters
Option Explicit
 
Public Function IsAlphaNumeric(sExpression As String) As Boolean
'Returns True if all characters in a string are alphabetical or numeric
'Returns False otherwise or for empty string
    Dim sTemp As String
    Dim iLen As Integer
    Dim iCount As Integer
    Dim sChar As String
 
    sTemp = sExpression
    iLen = Len(sTemp)
    If iLen > 0 Then
        For iCount = 1 To iLen
            sChar = Mid(sTemp, iCount, 1)
            If Not sChar Like "[0-9A-Za-z]" Then Exit Function
        Next
        IsAlphaNumeric = True
    End If
End Function

Related posts:

  1. How to check if a string contains only Numeric Characters
  2. How to check if a string contains only Alphabetical Characters
  3. How to Test if a character is Alpha Numeric.
  4. How to Remove all Non Alpha Numeric characters from a given string
  5. How to Strip Non Alpha Numeric from a string
  6. How to Strip special characters from a given String
  7. How to Remove all numeric characters from a string
  8. How to Strip Numeric from a string
  9. How to check whether given string is numeric or not without using IsNumeric function.
  10. How to remove Duplicate characters from a string

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.