这是机房收费系统的第一个窗体,所以它很重要,这个窗体和我们刚敲完的学生格外的相似,登录界面都是一样的,所以可以借鉴那个的登录窗体,首先来理一下这个思路:
以下是代码部分,希望可以帮助到大家
Private Sub cmdOk_Click()
'用来存放SQL语句
Dim txtsql As String
' 用来存放记录集对象
Dim mrc As ADODB.Recordset
'用来存放返回信息
Dim msgtext As String
UserName = ""
'判断输入用户名是否为空
If Not testtxt(txtUserName.Text = "") Then
MsgBox "没有这个用户,请注册!", 0 + 48, "警告"
Else
UserName = Trim(txtUserName.Text)
'查询指定用户名的记录
txtsql = "select * from user_info where userID = '" & UserName & "'"
'执行查询语句
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", 0 + 48, "警告"
txtUserName.SetFocus
txtUserName = ""
txtPassword = ""
Exit Sub
Else
'判断输入密码是否正确
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
frmMain.Show
Else
MsgBox "输入密码不正确,请重新输入!", 0 + 48, "警告"
txtUserName.SetFocus
txtUserName = ""
txtPassword = ""
Exit Sub
End If
End If
End If
micount = micount + 1
If micount < 3 Then
Me.Hide
End If
End Sub
以上是我刚敲得登录窗体部分,如果有哪些地方做的不好,需要改进,希望小伙伴可以指出!