使用VB语言制作登陆界面
2016-06-02 18:02
357 查看
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 中 copymemory的有关问题
- 没有找到msvbvm60.dll,因此这个应…
- 银河U1 VB 真空烧 + 银河北斗 + 锐科特小蓝火
- office2007给VBA增加数字签名保证宏安全
- 【原创】VB6.0应用程序安装包的生成(Setup Factory 9.0制作安装包的方法)
- 基于ffmpeg的内存数据UDP直播推流
- 【办公-WORD】vba 统一改变word文档所有的图片大小 然后导出成PDF
- 计算Spearman等级相关系数的VBA函数
- VB实现USB摄像头视频图像的监控、截图、录像
- 2016年4月编程语言排行榜 Visual Basic正渐行渐远
- VB Cells.find函数参数解释
- 安装vbundle
- excel中用当天日期命名工作表名vba
- 对反正弦函数的泰勒公式的转换加速
- VB 颜色RGB
- VB.net学习笔记(二十三)再识委托
- vbox丢失*MultiArch_amd64.msi或者*MultiArch_x86.msi重新制作
- VBA编程之放假倒计时器