文档详情

VB实例讲解二.doc

发布:2017-12-10约1.49万字共12页下载文档
文本预览下载声明
内容: ?????? 做个登陆程序,以VB+Access。 功能: ??????1、验证。验证用户名的正确与否、密码与用户名符合与否 ??????2、人性化设计。 ????????????①、输入用户名后,无论是鼠标移动到密码框,还是按“Tab”键到密码框,都搜索用户名的存在与否,但不报错 ????????????②、输入密码后,选者状态在“确定”按钮上。 ????????????③、确定后检验,用户名为空时,光标停在用户名框,密码空停密码输入框。 控件: ??????TextBox、CommandButton、PictureBox、Timer、ADO 程序内容: ①:控件 ???? 2???? TextBox ???? 2???? CommandButton ???? 1???? PictureBox ???? 1???? Timer ②:程序 ?????? form1程序 Private Sub Command1_Click() ?? Unload Me End Sub Private Sub Command2_Click() ?? Dim ConStr As String ?? If text_user.Text = Then ??????MsgBox 请输入用户名!, vbOKOnly + vbExclamation, 登陆错误 ??????text_user.SetFocus ??????Exit Sub ?? End If ???? ?? Set cn = New ADODB.Connection ?? Set rs = New ADODB.Recordset ?? ConStr = Provider=Microsoft.Jet.OLEDB.4.0; Data Source= App.Path \ttj02.Mdb ?? cn.Open ConStr ?? cn.CursorLocation = adUseServer ?? rs.Open Select * from dbuser, cn, adOpenKeyset, adLockPessimistic ?? If rs.RecordCount 0 Then ??????If text_user.Text Then ???????? Set rs1 = New ADODB.Recordset ???????? Dim TextUserName ???????? TextUserName = Left(text_user.Text, 4) ???????? rs1.Open Select * From dbuser Where User_nb= TextUserName , cn, adOpenKeyset, adLockPessimistic ???????? If rs1.RecordCount 0 Then ????????????text_user.Text = Left(text_user.Text, 4) rs1.Fields(user_zhuwu) ????????????Text_password.SetFocus ????????????If Text_password Then ?????????????? If rs1.Fields(User_Nb) = TextUserName And rs1.Fields(User_password) = Text_password.Text Then ??????????????????Form3.Show ??????????????????Unload Me ?????????????? Else ??????????????????MsgBox 密码错误!, vbExclamation + vbOKCancel, 登陆错误 ??????????????????text_user.Text = ??????????????????Text_password = ??????????????????text_user.SetFocus ?????????????? End If ????????????Else ?????????????? MsgBox 请输入密码!, vbExclamation + vbOKCancel, 登陆错误 ????????????End If ???????? Else ????????????MsgBox 沒有用戶信息,請確定!, vbExclamation + vbOKCancel, 登陆错误 ????????????text_user.Text = ????????????Text_password = ????????????t
显示全部
相似文档