text1 用户名
text2 原密码
text3 新密码
text4 新密码确认
Cmd_OK 确定
Cmd_Cancel 取消~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Cmd_OK_Click()If Trim(Text1.Text) = "" Then
MsgBox "用户名不能为空!", vbExclamation + vbOKOnly, "警告"
Text1.SetFocus
ElseIf Text1.Text <> Data1.Recordset("username") Then
MsgBox "用户名不存在!", vbExclamation + vbOKOnly, "提示"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
ElseIf Trim(Text2.Text) = "" Or Trim(Text3.Text) = "" Or Trim(Text4.Text) = "" Then
MsgBox "密码不能为空!", vbExclamation + vbOKOnly, "警告"ElseIf Text3.Text <> Text4.Text Then
MsgBox "两次密码输入不相同!", vbExclamation + vbOKOnly, "警告"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocusElseIf Text2.Text <> Data1.Recordset("password") Then
MsgBox "原密码不正确!", vbExclamation + vbOKOnly, "提示"
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text2.SetFocus
Else
a = "username='" & Text1.Text & "'"
Data1.Recordset.FindFirst (a)
Data1.Recordset.Edit
Data1.Recordset.Fields(1) = Text3.Text
Data1.Recordset.Update
MsgBox "保存成功! ", vbOKOnly + vbInformation, "提示"
Unload MeEnd IfEnd SubPrivate Sub Cancel_Click()
Unload Me
End Sub
text2 原密码
text3 新密码
text4 新密码确认
Cmd_OK 确定
Cmd_Cancel 取消~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Cmd_OK_Click()If Trim(Text1.Text) = "" Then
MsgBox "用户名不能为空!", vbExclamation + vbOKOnly, "警告"
Text1.SetFocus
ElseIf Text1.Text <> Data1.Recordset("username") Then
MsgBox "用户名不存在!", vbExclamation + vbOKOnly, "提示"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
ElseIf Trim(Text2.Text) = "" Or Trim(Text3.Text) = "" Or Trim(Text4.Text) = "" Then
MsgBox "密码不能为空!", vbExclamation + vbOKOnly, "警告"ElseIf Text3.Text <> Text4.Text Then
MsgBox "两次密码输入不相同!", vbExclamation + vbOKOnly, "警告"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocusElseIf Text2.Text <> Data1.Recordset("password") Then
MsgBox "原密码不正确!", vbExclamation + vbOKOnly, "提示"
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text2.SetFocus
Else
a = "username='" & Text1.Text & "'"
Data1.Recordset.FindFirst (a)
Data1.Recordset.Edit
Data1.Recordset.Fields(1) = Text3.Text
Data1.Recordset.Update
MsgBox "保存成功! ", vbOKOnly + vbInformation, "提示"
Unload MeEnd IfEnd SubPrivate Sub Cancel_Click()
Unload Me
End Sub
菜单:工程->引用->Microsoft Access Data Object 2...
Private Sub Command1_Click()
If Text1.Text <> UserPass Then
MsgBox "旧密码输入错误,请重新输入!", vbOKOnly + vbExclamation, "错误"
Text1.SelStart = 0
Text1.SelLength = Len(Text3.Text)
Text1.SetFocus
Exit Sub
End If
If Text3.Text <> Text2.Text Then
MsgBox "新密码两次输入不一致,请重新输入!", vbOKOnly + vbExclamation, "错误"
Text3.SelStart = 0
Text3.SelLength = Len(Text3.Text)
Text3.SetFocus
Exit Sub
End If
Dim cn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim SqlStr As String
cn.CursorLocation = adUseClient
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Mode=ReadWrite;Persist Security Info=False;Jet OLEDB:Database Password=123456"
SqlStr = "Select * FROM 用户 Where 用户名称 = '" & UserName & "'"
rst.Open SqlStr, cn, adOpenDynamic, adLockOptimistic, adCmdText
rst.Fields("用户密码").Value = Text3.Text
rst.UpdateBatch
rst.Close
cn.Close
MsgBox "密码修改成功!", vbOKOnly + vbInformation, "正确"
Unload Me
End Sub
Data1.Refresh试试