CodeItBetter Programming Another VB Programming Blog

How to check if a string contains only Alphabetical 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 Alphabetical Characters
Option Explicit
 
Public Function IsAlphaBetical(sExpression As String) As Boolean
'Returns True if all characters in a string are alphabetical
'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 "[A-Za-z]" Then Exit Function
        Next
        IsAlphaBetical = True
    End If
End Function
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.