VBScript function to check if value is a letter

Is there any VBScript function to check if a value is a letter, such as IsNumeric() for numbers?
Who is Participating?
Bill PrewConnect With a Mentor Commented:
Here's a slightly lighter version that just checks for upper and lower case letters.

Wscript.Echo IsAlpha("testString")
Wscript.Echo IsAlpha("test String")

Function IsAlpha(s)
   Dim r, m
   Set r = New RegExp
   r.Pattern = "^[A-Za-z]*$"
   Set m = r.Execute(s)
   If m.Count = 0 Then
      IsAlpha = False
      IsAlpha = True
   End If
   Set w = Nothing
   Set r = Nothing
End Function

Open in new window

Bill PrewCommented:
No built in function in VBS for this, but you could write a small function to do it.  Here's a simple example of using regular expressions to implement it.


Bill PrewCommented:
Looking at that example I think we could simplify a bit, what characters do you want to pass, just a-z and A-Z, or any others like space, etc?

Carlos_FelipeAuthor Commented:
I did something simple:

If Asc(UCase(strBranchDrive))=>65 And Asc(UCase(strBranchDrive))=< 90 Then

Thank you all for the help!
Bill PrewCommented:
Yup, that will work too, I guess I sort of assumed you were looking for something more "interesting" thank that, but glad you have a solution, and thanks for the points.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.