📄 frmmodifypsw.frm
字号:
VERSION 5.00
Begin VB.Form frmmodifyPsw
Caption = "修改密码"
ClientHeight = 2880
ClientLeft = 60
ClientTop = 420
ClientWidth = 4095
Icon = "frmmodifyPsw.frx":0000
LinkTopic = "Form1"
ScaleHeight = 2880
ScaleWidth = 4095
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdtest
Caption = "检验用户名"
Height = 375
Left = 3000
TabIndex = 7
Top = 960
Width = 1095
End
Begin VB.CommandButton cmdreset
Caption = "重置"
Height = 375
Left = 2280
TabIndex = 6
Top = 2160
Width = 975
End
Begin VB.CommandButton cmdsubmit
Caption = "提交"
Height = 375
Left = 960
TabIndex = 5
Top = 2160
Width = 975
End
Begin VB.TextBox txtPsw
Height = 375
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 4
Top = 1380
Width = 1455
End
Begin VB.TextBox txtname
Height = 375
Left = 1560
TabIndex = 2
Top = 960
Width = 1455
End
Begin VB.Label lblPsw
Caption = "新 密 码"
Height = 255
Left = 240
TabIndex = 3
Top = 1440
Width = 1215
End
Begin VB.Label lblname
Caption = "用 户 名"
Height = 255
Left = 240
TabIndex = 1
Top = 1020
Width = 1095
End
Begin VB.Label lblmodify
Caption = "请输入您的用户名和新密码"
Height = 375
Left = 360
TabIndex = 0
Top = 360
Width = 2175
End
End
Attribute VB_Name = "frmmodifyPsw"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdreset_Click()
txtname.Text = ""
txtPsw.Text = ""
End Sub
Private Sub cmdsubmit_Click()
If checkform = False Then '对输入内容进行判断,如果不符合要求则不能登录
Exit Sub
End If
Dim strUsername, strNewPassword, strsqlup, strconn As String
strUsername = Trim(txtname.Text)
strNewPassword = Trim(txtPsw.Text)
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & _
App.Path & "\test.mdb;Persist Security Info=False" '连接access数据库
Dim conn As New ADODB.Connection
conn.ConnectionString = strconn
conn.Open
'On Error Resume Next
Dim stuname, stuPsw
stuname = Trim(txtname.Text)
stuPsw = Trim(txtPsw.Text)
'strsqlup = "update library set stuname='tt',bookname='tt',publish='tt',price='30',auther='tt',borrow_date='2005/1/1 ' where stuid='1 '"
strsqlup = "update User set Password='123' where UserName='admin '"
'strsqlup = "update User set Password='" & stuPsw & "' where UserName='" & stuname & " '"
conn.Execute (strsqlup)
If Err.Number = 0 Then
MsgBox "您的密码已经修改成功 !"
Else
MsgBox Err.Description
End If
conn.Close
Set conn = Nothing
End Sub
Private Function checkform() As Boolean
Dim strUsername, strNewPassword
strUsername = Trim(txtname.Text)
strNewPassword = Trim(txtPsw.Text)
If strUsername = "" Then
MsgBox "用户名不能为空,请输入用户名!" '判断用户名是否为空
txtname.SetFocus
checkform = False
Exit Function
End If
If strNewPassword = "" Then
MsgBox "密码不能为空,请输入密码!" '判断密码是否为空
txtPsw.SetFocus
checkform = False
Exit Function
End If
End Function
Private Sub cmdtest_Click()
Dim strUsername, strNewPassword, strsqlsl, strconn As String
strUsername = Trim(txtname.Text)
strNewPassword = Trim(txtPsw.Text)
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & _
App.Path & "\test.mdb;Persist Security Info=False" '连接access数据库
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.ConnectionString = strconn
conn.Open
strsqlsl = "Select Top 1 UserName,Password From [User] WHERE UserName= '" & strUsername & "'"
rs.Open strsqlsl, conn, 1, 1 '对输入内容与数据库中的数据进行比较
If rs.RecordCount = 0 Then
MsgBox "该用户不存在,请核对!"
txtname.Text = ""
txtname.SetFocus
rs.Close
conn.Close
Set rs = Nothing
Else
MsgBox "用户名存在,请继续操作!"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -