VB中设置登录界面的代码
2016-05-26 17:19
513 查看
Option Explicit
Const MaxLoginTimes As Integer = 3
Private Sub cmdLogin_Click()
Static loginTimes As Integer
loginTimes = loginTimes + 1
If loginTimes < MaxLoginTimes Then
On Error GoTo ppp
Dim Cn As Connection
Dim Rs As Recordset
Dim strSQL As String
Set Cn = New Connection
Set Rs = New Recordset
Cn.ConnectionString = " provider=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Users\jf\Desktop\TestExample.mdb"
Cn.Open
Rs.ActiveConnection = Cn
strSQL = "select UserPassword from UserInformation where UserID= '" & Me.txtUserID.Text & "'"
Rs.Open (strSQL)
If Rs.EOF = True Then
MsgBox txtUserID.Text & "不存在"
Me.txtUserID.SetFocus
Me.txtUserID.SelStart = 0
Me.txtUserID.SelLength = Len(Me.txtUserID.Text)
Else
If Rs.Fields("UserPassword").Value = Me.txtPassword.Text Then
MsgBox "登录成功"
Unload Me
'frmNew.show
Else
MsgBox "密码错误"
End If
End If
ppp:
Cn.Close
Else
MsgBox "亲,您的输入次数超过允许的最大次数", vbCritical, "登录"
End If
End Sub
Const MaxLoginTimes As Integer = 3
Private Sub cmdLogin_Click()
Static loginTimes As Integer
loginTimes = loginTimes + 1
If loginTimes < MaxLoginTimes Then
On Error GoTo ppp
Dim Cn As Connection
Dim Rs As Recordset
Dim strSQL As String
Set Cn = New Connection
Set Rs = New Recordset
Cn.ConnectionString = " provider=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Users\jf\Desktop\TestExample.mdb"
Cn.Open
Rs.ActiveConnection = Cn
strSQL = "select UserPassword from UserInformation where UserID= '" & Me.txtUserID.Text & "'"
Rs.Open (strSQL)
If Rs.EOF = True Then
MsgBox txtUserID.Text & "不存在"
Me.txtUserID.SetFocus
Me.txtUserID.SelStart = 0
Me.txtUserID.SelLength = Len(Me.txtUserID.Text)
Else
If Rs.Fields("UserPassword").Value = Me.txtPassword.Text Then
MsgBox "登录成功"
Unload Me
'frmNew.show
Else
MsgBox "密码错误"
End If
End If
ppp:
Cn.Close
Else
MsgBox "亲,您的输入次数超过允许的最大次数", vbCritical, "登录"
End If
End Sub
相关文章推荐
- vb 中输入个人信息并保存到文档中
- vb
- vb
- VB 文档删除和改名
- [OpenGL ES 06]使用VBO:顶点缓存
- VB用End退出,不会发生Form_Unload事件
- VB .NET周期实现
- DVB电视机顶盒工作原理
- setvbuf()创建缓冲区函数
- IIS7.5 Microsoft VBScript runtime error '800a0046'的解决
- win10 完美屏蔽Flash右键菜单,内存播放Flash swf 文件(VC、 VB)f_in_box4.4 最新破解版
- VBA 每日文件按日期打包存放
- VBA进度条
- fopen的默认缓冲大小和setvbuf 用法
- AM335x OTG VBUS电路设计的一些注意要点
- Vb.net-DatagridView之右击删除选中行
- VBS ConvertToXlsx
- VBScipt脚本输出
- 【VB.net】DataGridView控件的使用
- VB.net学习笔记(二十二)XML的DOM模型读写