📄 frmpwd.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form FrmPWD
BorderStyle = 3 'Fixed Dialog
Caption = "修改密码"
ClientHeight = 4425
ClientLeft = 45
ClientTop = 330
ClientWidth = 5115
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4832.765
ScaleMode = 0 'User
ScaleWidth = 5230.679
ShowInTaskbar = 0 'False
Begin VB.TextBox txtUserName
Height = 375
Left = 2520
TabIndex = 0
Top = 240
Width = 1575
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 1680
Top = 3720
Visible = 0 'False
Width = 1200
_ExtentX = 2117
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=personnel"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "personnel"
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "user"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 2880
TabIndex = 6
Top = 3240
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "修改"
Height = 375
Left = 600
TabIndex = 4
Top = 3240
Width = 1575
End
Begin VB.TextBox txtNewPWD2
DataSource = "Adodc1"
Height = 375
IMEMode = 3 'DISABLE
Left = 2520
PasswordChar = "*"
TabIndex = 3
Top = 2400
Width = 1575
End
Begin VB.TextBox txtNewPWD1
Height = 375
IMEMode = 3 'DISABLE
Left = 2520
PasswordChar = "*"
TabIndex = 2
Top = 1680
Width = 1575
End
Begin VB.TextBox txtPWD
Height = 375
IMEMode = 3 'DISABLE
Left = 2520
PasswordChar = "*"
TabIndex = 1
Top = 960
Width = 1575
End
Begin VB.Label Label4
Caption = "确认新密码:"
Height = 375
Left = 600
TabIndex = 9
Top = 2520
Width = 1575
End
Begin VB.Label Label3
Caption = "输入新密码:"
Height = 375
Left = 600
TabIndex = 8
Top = 1800
Width = 1455
End
Begin VB.Label Label2
Caption = "输入原密码:"
Height = 375
Left = 600
TabIndex = 7
Top = 1080
Width = 1455
End
Begin VB.Label Label1
Caption = "输入用户名:"
Height = 375
Left = 600
TabIndex = 5
Top = 360
Width = 1575
End
End
Attribute VB_Name = "FrmPWD"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'判断密码是否与用户名相符
Private Function rightPWD(name As String, PWD As String) As Boolean
name = "'" & name & "'"
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "username=" & name
If Adodc1.Recordset("pwd") = PWD Then
rightPWD = True
Else
rightPWD = False
End If
End Function
'判断姓名是否存在
Private Function nameExist(name As String) As Boolean
Dim i As Integer
i = 0
Adodc1.Recordset.MoveFirst
While (Not Adodc1.Recordset.EOF)
If Adodc1.Recordset("username") = name Then
i = i + 1
End If
Adodc1.Recordset.MoveNext
Wend
If i = 0 Then
nameExist = False
Else
nameExist = True
End If
End Function
Private Sub Command1_Click()
If (txtUserName.Text <> "") And (txtPWD.Text <> "") And (txtNewPWD1.Text <> "") And (txtNewPWD2.Text <> "") Then
If nameExist(txtUserName.Text) Then
If rightPWD(txtUserName.Text, txtPWD.Text) Then
If txtNewPWD1.Text = txtNewPWD2.Text Then
Dim user As String
user = txtUserName.Text
user = "'" & user & "'"
Adodc1.Recordset.MoveFirst
'找到用户名所在行
Adodc1.Recordset.Find "username=" & user
'保存新密码
Adodc1.Recordset("pwd") = txtNewPWD1.Text
Adodc1.Recordset.UpdateBatch
MsgBox "修改密码成功!", vbOKOnly + vbInformation, "提示信息"
Unload Me
Else
MsgBox "两次输入密码不一样,请确认!", vbOKOnly + vbExclamation, "提示信息"
End If
Else
MsgBox "用户名与原密码不符,请重新输入!", vbOKOnly + vbExclamation, "提示信息"
End If
Else
MsgBox "用户不存在,请重新输入用户名!", vbOKOnly + vbExclamation, "提示信息"
End If
Else
MsgBox "请输入完整信息!", vbOKOnly + vbExclamation, "提示信息"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -