KeyPress Event occurs when the user presses and releases an ANSI key and I need same the Event for UNICODE character set.


My intention is to use KeyPress Event with the InStr function to prevent a user from typing characters like '\/*?""<>|

Code:

Public Const conAppInvalidCharacters = "'\/*?""<>|"
Public Const conAppCharacterSubstitute = "~"

Private Sub someTextBoxControlName_KeyPress(KeyAscii As Integer)
If InStr(1, conAppInvalidCharacters, Chr(KeyAscii), vbTextCompare) Then
KeyAscii = Asc(conAppCharacterSubstitute)
End If
End Sub

This sub works perfectly with an ANSI codes, but an Error occurs when the user types chars like š,č,ž etc.

Any ideas?
Thx