Originally Posted by
June7
Show code for the AlphaNumericName procedure.
Or instead of calling that function:
If characterSwap Like "[!a-Z]" Then
Your code seems to work (I used my suggested change).
Ooops, might what to handle ESC and space same as backspace.
Case 8, 27, 32
Also, what about contracted (apostrophe, code 39) and hyphenated (hyphen, code 45) names?
Code:
Function AlphaNumericName(pValue) As Boolean
Dim LPos As Integer
Dim LChar As String
Dim LValid_Values As String
'Start at first character in pValue
LPos = 1
'Set up values that are considered to be alphanumeric
LValid_Values = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'’-"
'Test each character in pValue
While LPos <= Len(pValue)
'Single character in pValue
LChar = Mid(pValue, LPos, 1)
'If character is not alphanumeric, return FALSE
If InStr(LValid_Values, LChar) = 0 Then
AlphaNumericName = False
Exit Function
End If
'Increment counter
LPos = LPos + 1
Wend
'Value is alphanumeric, return TRUE
AlphaNumericName = True
End Function
Yes there's a few keys I tried to account for - sending delete key to equal the letter "a" was one of them (since for some reason there was no chr() for delete key and came up as a dot)