ImputValidation




Function ValiText(KeyIn As Integer, _
ValidateString As String, _
Editable As Boolean) As Integer

Dim ValidateList As String
Dim KeyOut As Integer
'

If Editable = True Then
ValidateList = UCase(ValidateString) & Chr(8)
Else
ValidateList = UCase(ValidateString)
End If
'

If InStr(1, ValidateList, UCase(Chr(KeyIn)), 1) > 0 Then
KeyOut = KeyIn
Else
KeyOut = 0
Beep
End If
'

ValiText = KeyOut
'

End Function
Then, for each control whose input you wish to validate, just
put something like this in the KeyPress event of the control:
KeyAscii=ValiText(Keyascii, "0123456789/-",True)

Doing so will filter out any undesired keys that go to the
control, accepting only the keys defined by the second
parameter. In this case, that parameter ("0123456789/-")
defines characters that are valid for a date.

The function's third parameter controls whether the [Backspace]
key can be used.

Note that this implementation of the function ignores the case
of the incoming keys, so if your second parameter were "abcdefg",
the function would also allow "ABCDEFG" to be entered.










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