Results 1 to 5 of 5

Thread: disable some key in keyboard

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    1
    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

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124
    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

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    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

  4. #4
    Addicted Member Rohan_Powle's Avatar
    Join Date
    Mar 2000
    Location
    Mumbai,maharashtra.India
    Posts
    173
    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

  5. #5
    Lively Member
    Join Date
    Jun 1999
    Posts
    120

    KeyCode Event?

    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...



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width