IsAlphaNum




Public Function IsAlpha(str As String) As Boolean
Dim InvalidCharFound As Boolean
Dim x As String
Dim i As Integer
Dim AsciiVal As Integer
If Len(str) > 0 And str <> vbNullString Then
For i = 1 To Len(str)
x = Mid(str, i, 1)
AsciiVal = Asc(x)
'The ASCII values here are "acceptable" values for the function.

'This code allows lower-case letters, upper-case letters, commas,

'periods, double and single quotes, hyphens, and spaces.

'It can be modified to include or exclude any ASCII values.

If Not ((AsciiVal > 64 And AsciiVal < 91) Or _
(AsciiVal > 96 And AsciiVal < 123) Or AsciiVal = 34 Or _
AsciiVal = 36 Or AsciiVal = 39 Or (AsciiVal > 43 And AsciiVal < 47)) Then
InvalidCharFound = True
End If
Next i
IsAlpha = Not InvalidCharFound
Else
IsAlpha = False
End If
End Function










( isalphanum.html )- by Paolo Puglisi - Modifica del 17/12/2023