in the textbox's Keypress event, and the user will not be able to type a
hyphen, but instead will hear a beep. If you want to disallow certain
other
characters, add them to the parameter string.
Sorry (I'm a learner) but I don't get it! Believe me it's not he only
thing I don't get. I was intrigued with/by this wee function and I
tried to set it up on an unbound control in a form as suggested. (I
think). The part I don't get so far is where is the defined content of
string "Excludes". The string seems to me to be at the end of the line
that starts with the word "Syntax:".
Could someone please expound? Code is below .....
Public Function KeyFilter(KeyAscii As Integer, Excludes As String)
' Called from keypress event of a textbox
' Disallows all characters found in Excludes
'
'Syntax: KeyFilter KeyAscii, "!£$%^&*()\/|?'#~@;:[]{}-_=+"
Select Case KeyAscii
Case 8, 9, 13, 27 'Backspace, Tab, Enter, Esc
Exit Function
End Select
If InStr(1, Excludes, Chr$(KeyAscii)) Then
Beep
KeyAscii = 0
End If
End Function
I placed the (KeyFilter KeyAscii, "-" ) in the OnKeyPress event and I
get the error message (no number) ....
MOA cannot find the macro (KeyFilter KeyAscii, "-" )No brackets on
error message.
I have also tried removing the ('Syntax
from the line above but I
still don't get it. Please help ... I love to learn!