修改密码:
窗体界面:
代码如下:
Option Explicit
Private Sub CmdCancel_Click()
Unload Me
End Sub
Private Sub CmdOk_Click()
Dim objrs As ADODB.Recordset
Dim strsql As String
Dim Msgtxt As String
strsql = "select * from User_Info where User_Name='" & UserName & "'"
Set objrs = ExecuteSQL(strsql, Msgtxt)
'如果用户名输入正确
If Trim(objrs.Fields(1)) = Trim(TxtoldPassword.Text) Then
'两次密码输入一样,则修改成功
If Trim(TxtnewPassword.Text) = Trim(TxtensurePassword.Text) Then
objrs.Fields(1) = Trim(TxtnewPassword.Text)
objrs.Update
objrs.Close
MsgBox "修改密码成功!", vbOKOnly + vbExclamation, "祝贺"
Me.Hide
Else
'两次密码不一致,重新输入
MsgBox "两次密码不一致,请重新输入新口令!", vbOKOnly + vbExclamation, "警告"
TxtnewPassword.Text = ""
TxtensurePassword.Text = ""
TxtnewPassword.SetFocus
Exit Sub
End If
Else
'口令不正确,重新输入
MsgBox "您输入的口令不正确,请重新输入口令!", vbOKOnly + vbExclamation, "警告"
TxtoldPassword.Text = ""
TxtoldPassword.SetFocus
Exit Sub
End If
End Sub