键盘锁不是VB写的控件有漏洞,而是你用SendKey的原因,我以前用此功能经常出现键盘被锁的现象,找了很久才查明此原因,建议不使用此功能。如果没有使用Sendkey哪就另当别论了。漏洞不在于用什么语言写的,任何语言写的控件如果写的不好,都可能有漏洞的.

解决方案 »

  1.   

    '
    '注意!不要删除或修改下列被注释的行!
    'MappingInfo=txtActive,txtActive,-1,Enabled
    Public Property Get Enabled() As Boolean
        Enabled = txtActive.Enabled
        'UserControl.Enabled = Enabled
    End PropertyPublic Property Let Enabled(ByVal New_Enabled As Boolean)
        txtActive.Enabled() = New_Enabled
        PropertyChanged "Enabled"
        UserControl.Enabled = New_Enabled 'txtActive.Enabled()
        
    End Property'注意!不要删除或修改下列被注释的行!
    'MappingInfo=txtActive,txtActive,-1,Refresh
    Public Sub Refresh()
        txtActive.Refresh
    End SubPrivate Sub txtActive_Click()
        RaiseEvent Click
    End SubPrivate Sub txtActive_DblClick()
        RaiseEvent DblClick
    End SubPrivate Sub txtActive_KeyDown(KeyCode As Integer, Shift As Integer)
        RaiseEvent KeyDown(KeyCode, Shift)
    End SubPrivate Sub txtActive_KeyPress(KeyAscii As Integer)
        Dim blnDot As Boolean
        Dim strText As String
        
        blnDot = False
        
        If KeyAscii = 45 Then
            KeyAscii = 0
            txtActive.Text = ""
            Exit Sub
        End If
        
        If KeyAscii = 42 Then
            KeyAscii = 0
            SendKeys "+{tab}"
            Exit Sub
        End If
        
        If KeyAscii = vbKeyReturn Then
            SendKeys "{tab}"
            Exit Sub
        End If
        
        If KeyAscii = 8 Then
            Exit Sub
        End If
        
        Select Case m_InputType
            Case 0:
                If KeyAscii < 48 Or KeyAscii > 57 Then
                    KeyAscii = 0
                End If
            Case 1:
                strText = Me.Text
                If InStr(strText, ".") > 0 Then
                    blnDot = True
                End If
                If KeyAscii = 46 Then
                    If blnDot Then
                        KeyAscii = 0
                    End If
                    Exit Sub
                End If
                If (KeyAscii < 48 Or KeyAscii > 57) Then
                    KeyAscii = 0
                End If
                
            Case Else:
                
        End Select
        
        RaiseEvent KeyPress(KeyAscii)
    End SubPrivate Sub txtActive_KeyUp(KeyCode As Integer, Shift As Integer)
        RaiseEvent KeyUp(KeyCode, Shift)
    End SubPrivate Sub txtActive_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        RaiseEvent MouseDown(Button, Shift, X, Y)
    End SubPrivate Sub txtActive_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        RaiseEvent MouseMove(Button, Shift, X, Y)
    End SubPrivate Sub txtActive_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        RaiseEvent MouseUp(Button, Shift, X, Y)
    End Sub以上就是我自己写的部分,剩下的VB自动生成的没有贴。