有关本窗体的代码如下:
Option Explicit
Dim pwdCount As Integer
Private Sub cmdCancel_Click()
Unload Me
Exit Sub
End Sub
Private Sub cmdOK_Click()
Dim SQL As String
Dim rs As ADODB.Recordset
If Trim(UserName.Text = "") Then
MsgBox "没有输入用户名称,请重新输入!", vbOKOnly + vbExclamation, "警告"
UserName.SetFocus
Else '查询用户
SQL = "select * from UserInfo where UserID='" & UserName.Text & "'"
Set rs = TransactSQL(SQL)
If iflag = 1 Then
If rs.EOF = True Then
msgBox "没有这个用户,请重新输入!",vbOKOnly + vbExclamation,"警告"
UserName.SetFocus
Else
If Trim(rs.Fields(1)) = Trim(PassWord.Text) Then
rs.Close
Me.Hide
gUserName = Trim(UserName.Text)'保存用户名称
FrmMain.Show
Unload Me
Else
MsgBox "密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
PassWord.SetFocus
PassWord.Text = ""
End If
End If
Else
Unload Me
End If
End If
pwdCount=pwdCount+1 '判断输入次数
If pwdCount = 3 Then
Unload Me
Exit Sub
End If
End Sub
Private Sub Form_Load()
pwdCount = 0
gUserName = ""
End Sub
Private Sub PassWord_KeyDown(KeyCode As Integer, Shift As Integer)
TabToEnter KeyCode
End Sub
Private Sub UserName_KeyDown(KeyCode As Integer, Shift As Integer)
TabToEnter KeyCode
End Sub
3、系统主界面的设计效果