Someone may have a butter way, but mine is
in the textbox afterupdate event, I scan the whole word to remove bad characters, usage:
Code:
sub txtBox_Afterupdate()
txtBox = FixBadChrsInWord(txtBox)
end sub
paste this in a module.
Code:
Public Function FixBadChrsInWord(ByVal pvWord)
Dim i As Integer
Dim vChr, vNewWord
On Error Resume Next
pvWord = UCase(Trim(pvWord))
For i = 1 To Len(pvWord)
vChr = Mid(pvWord, i, 1)
vChr = FixBadChar(vChr)
vNewWord = vNewWord & vChr
Next
FixBadChrsInWord = vNewWord
End Function
private Function FixBadChar(ByVal pvChr)
'bad chars if:
'after UCASE the 1 character entered
'then check these bad ranges:
Dim iChrNum As Integer
pvChr = UCase(pvChr)
iChrNum = Asc(pvChr)
Select Case True
'period OK
Case iChrNum = 46
FixBadChar = pvChr
Case iChrNum > 32 And iChrNum < 48
FixBadChar = ""
Case iChrNum > 57 And iChrNum < 65
FixBadChar = ""
Case iChrNum > 91 And iChrNum < 127
FixBadChar = ""
Case Else
FixBadChar = pvChr
End Select
End Function