我把一个“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 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_ClickEnd SubPrivate 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