hi,
I'd like to disable some key is keyboard such as ALT, TAB; or another, for forcing the user to tape a valid username and password before using some application in the computer.
thanks
Printable View
hi,
I'd like to disable some key is keyboard such as ALT, TAB; or another, for forcing the user to tape a valid username and password before using some application in the computer.
thanks
You can start with this function and modify it to make restrict keys if you like. This function will only allow the user enter the Keys you specify on the keyboard.
Code:Public Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = fnValiText
(KeyAscii,"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",True)
End Sub
Public Function fnValiText(arg_sKeyIn As Integer, arg_strValidateString As String, arg_bEditable As Boolean) As Integer
'Dim member variables
Dim m_strValidateList As String
Dim m_sKeyOut As Integer
If arg_bEditable = True Then
m_strValidateList = UCase(arg_strValidateString) & Chr(8)
Else
m_strValidateList = UCase(arg_strValidateString)
End If
If InStr(1, m_strValidateList, UCase(Chr(arg_sKeyIn)), 1) > 0 Then
m_sKeyOut = arg_sKeyIn
Else
m_sKeyOut = 0
End If
fnValiText = m_sKeyOut
End Function
you can use this...
Private Sub Text1_KeyPress (KeyAscii As Integer)
If KeyAscii = 9 or KeyAscii = 18 then KeyAscii = 0
'Note KeyAscii 8 = TAB Key and KeyAscii 18 = Atl Key.
End Sub
Every body Uses keyascii but as per my Knowledge
KEYCODE Event is the best to trap Keys...
Because it traps even the Function keys....which is not possible with ascii....
use if condition and trap the keys
eg:- if keycode = vbkeyreturn then
----
End if
Try it
there's no KeyCode Event... BUT
KeyDown and KeyUp Events use KeyCode as one of their
parameters...
for example:
Private Sub Text1_KeyDown (KeyCode As Integer, Shift As Integer)
just a clarification...:)