📄 frmchangepassword.frm
字号:
VERSION 5.00
Begin VB.Form frmChangePassword
BorderStyle = 1 'Fixed Single
Caption = "修改密码"
ClientHeight = 3225
ClientLeft = 45
ClientTop = 435
ClientWidth = 5715
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 3225
ScaleWidth = 5715
Begin VB.CommandButton Command2
Caption = "取 消"
Height = 375
Left = 3000
TabIndex = 8
Top = 2520
Width = 1000
End
Begin VB.CommandButton Command1
Caption = "修 改"
Height = 375
Left = 1320
TabIndex = 7
Top = 2520
Width = 1000
End
Begin VB.TextBox txtConfirm
Height = 270
IMEMode = 3 'DISABLE
Left = 2280
PasswordChar = "*"
TabIndex = 6
Top = 1920
Width = 2055
End
Begin VB.TextBox txtNew
Height = 270
IMEMode = 3 'DISABLE
Left = 2280
PasswordChar = "*"
TabIndex = 5
Top = 1440
Width = 2055
End
Begin VB.TextBox txtOld
Height = 270
IMEMode = 3 'DISABLE
Left = 2280
PasswordChar = "*"
TabIndex = 4
Top = 960
Width = 2055
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "确认新密码:"
Height = 180
Left = 960
TabIndex = 3
Top = 1965
Width = 1080
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "新 密 码:"
Height = 180
Left = 960
TabIndex = 2
Top = 1485
Width = 1080
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "旧 密 码:"
Height = 180
Left = 960
TabIndex = 1
Top = 1005
Width = 1080
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "修 改 密 码"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
Left = 1800
TabIndex = 0
Top = 240
Width = 2085
End
End
Attribute VB_Name = "frmChangePassword"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim OldPassword As String
Private Sub Command1_Click()
If CheckForm() = True Then
If txtOld.Text = OldPassword Then
Dim MyVar
MyVar = MsgBox("确认修改?", vbOKCancel, "信息提示")
If MyVar = vbOK Then
Dim strsql As String
strsql = "UPDATE MYUSERS SET [PASSWORD]= " & sys.StrToInsert(txtNew.Text) & " WHERE USERNAME= 'admin'"
sys.DB.ExecuteSQL (strsql)
MsgBox "恭喜,成功修改密码!下次请用新密码登录。"
Unload Me
End If
Else
MsgBox "请输入正确的旧密码!"
txtOld.Text = ""
txtOld.SetFocus
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Top = 0
Me.Left = 0
Me.Width = MainForm.Width * 0.45
Me.Height = MainForm.Height * 0.45
'取旧密码
Dim strsql As String
Dim rs As New ADODB.Recordset
strsql = "SELECT [PASSWORD] FROM MYUSERS WHERE USERNAME = 'admin'"
Set rs = sys.DB.OpenRecordSet(strsql)
If Not rs.EOF Then
OldPassword = sys.StrToText(rs("PASSWORD"))
End If
End Sub
'检查表单数据
Private Function CheckForm() As Boolean
CheckForm = False
If txtOld.Text = "" Then
MsgBox "旧密码不能为空!"
txtOld.SetFocus
ElseIf txtNew.Text = "" Then
MsgBox "新密码不能为空!"
txtNew.SetFocus
ElseIf txtConfirm.Text = "" Then
MsgBox "确认密码不能为空!"
txtConfirm.SetFocus
ElseIf txtNew.Text <> txtConfirm.Text Then
MsgBox "新密码和确认密码不一致!"
txtConfirm.SetFocus
Else
CheckForm = True
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -