>VBA Gerus,
>
[quoted text clipped - 5 lines]
>
>Charlie from Texas
To correct a misconception, ASCII (now called ANSI) characters include much more
than A-Z and a-z -- the digits, punctuation, and all other characters in the
range from 0 to 255 are 'ASCII characters'. So I wrote the function name as
IsAlpha instead.
Function IsAlpha(s As String) As Boolean
Dim retVal As Boolean
retVal = False
If Len(s) > 0 Then
If Left$(s, 1) Like "[A-Za-z]" Then
retVal = True
End If
End If
IsAlpha = retVal
End Function
Sub test()
Dim myText As String
Dim myChar As String
Dim msg As String
Dim i As Long
myText = Selection.Text
For i = 1 To Len(myText)
myChar = Mid$(myText, i, 1)
msg = "'" & myChar & "' is "
If Not IsAlpha(myChar) Then
msg = msg & "NOT "
End If
msg = msg & "in [A-Za-z]"
MsgBox msg
Next
End Sub
As written, this function checks only one character, the first one in the string
passed in as the parameter. If you meant to check a whole word or an entire
string, that would need some slightly different logic.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
Charlie Mac - 27 Feb 2008 14:49 GMT
Jay,
Thank you for your reply. I did not know that the "Like" function
existed. Your code solved my problem.
Take care,
Charlie from Texas
>>VBA Gerus,
>>
[quoted text clipped - 45 lines]
>passed in as the parameter. If you meant to check a whole word or an entire
>string, that would need some slightly different logic.