当前位置:编程学习 > VB >>

vb PictureBox KeyDown事件怎么写

我把一个“PictureBox”控件做成了按钮,该控件的Click 事件如下: 
Private Sub PicLogin_Click() 
If Combo.Text = "Administrator" And txtPassword.Text = "ljm2004" Then 
Frmmain.Show 
Frmmain.StatusBar1.Panels(2).Text = "当前系统用户: Administrator" 
Unload Me 
Else 
Adodc1.RecordSource = "select * from usertb where 名称='" + Trim(Combo) + "'" 
Adodc1.Refresh 
If Adodc1.Recordset.RecordCount > 0 Then 
If Trim(txtPassword) = Adodc1.Recordset.Fields("密码").Value Then 
Frmmain.Show 
Frmmain.StatusBar1.Panels(2).Text = "当前系统用户:" & Adodc1.Recordset.Fields("名称").Value 
Unload Me 
Else 
MsgBox "密码不正确!", vbExclamation + vbOKOnly 
End If 
Else 
MsgBox "无此用户或者密码不正确!", vbExclamation 
End If 
End If 
End Sub 
现在我想编写PicLogin_KeyDown事件,该怎么写?! --------------------编程问答-------------------- 代码可以这样:
Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer)

    If (KeyCode = 13) Then PicLogin_Click

End Sub

Private Sub PicLogin_Click()
    If Combo.Text = "Administrator" And txtPassword.Text = "ljm2004" Then
        Frmmain.Show
        Frmmain.StatusBar1.Panels(2).Text = "当前系统用户: Administrator"
        Unload Me
    Else
        Adodc1.RecordSource = "select * from usertb where 名称='" + Trim(Combo) + "'"
        Adodc1.Refresh
        If Adodc1.Recordset.RecordCount > 0 Then
            If Trim(txtPassword) = Adodc1.Recordset.Fields("密码").Value Then
                Frmmain.Show
                Frmmain.StatusBar1.Panels(2).Text = "当前系统用户:" & Adodc1.Recordset.Fields("名称").Value
                Unload Me
            Else
                MsgBox "密码不正确!", vbExclamation + vbOKOnly
            End If
        Else
            MsgBox "无此用户或者密码不正确!", vbExclamation
        End If
    End If
End Sub

补充:VB ,  基础类
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,