[分享]在VB中,实现修改密码的功能
Private Sub Command1_Click() Dim getmima As String, J As Integer, mima As String
'取得密码
With Adodc1
.ConnectionString = conn
.CommandType = 8
.RecordSource = "select * from login where username='" & userlogo & "'"
.Refresh
getmima = .Recordset.Fields("pass")
End With
'检确认密码与新密码是否一致
If Trim(Text1(2).Text) <> Trim(Text1(1).Text) Then
MsgBox "您输入的新密码与确认密码不符,请重新输入! ", vbExclamation, "提示"
Text1(1).Text = ""
Text1(2).Text = ""
Text1(1).SetFocus
Else
If DigestStrToHexStr(Text1(0)) = getmima Then
With Adodc1
.Recordset.Fields("pass") = DigestStrToHexStr(Text1(1))
.Recordset.Update
End With
MsgBox "非常好!密码已经修改完毕。请您牢记! ", vbExclamation, "提示"
Unload Me
Else
MsgBox "原密码不对,请确认后继续! ", vbExclamation, "提示"
Text1(0).Text = ""
Text1(1).Text = ""
Text1(2).Text = ""
Text1(0).SetFocus
End If
End If
End Sub
哈哈