Click to See Complete Forum and Search --> : disable some key in keyboard
voodoo_mg
Mar 21st, 2000, 04:19 PM
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
bsmith
Mar 21st, 2000, 07:37 PM
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.
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
Chris
Mar 21st, 2000, 09:57 PM
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
Rohan_Powle
Mar 23rd, 2000, 10:49 AM
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
KenX
Mar 23rd, 2000, 11:18 AM
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...:)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.