📄 frmuserupdate.frm
字号:
VERSION 5.00
Begin VB.Form frmUserUpdate
Caption = "修改用户"
ClientHeight = 4680
ClientLeft = 4605
ClientTop = 3360
ClientWidth = 5460
LinkTopic = "Form4"
ScaleHeight = 4680
ScaleWidth = 5460
Begin VB.CommandButton Command2
Caption = "取消"
Height = 495
Left = 2760
TabIndex = 9
Top = 3840
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 495
Left = 840
TabIndex = 8
Top = 3840
Width = 1335
End
Begin VB.TextBox txtOldPassword
Height = 375
IMEMode = 3 'DISABLE
Left = 2640
PasswordChar = "*"
TabIndex = 7
Top = 1320
Width = 1575
End
Begin VB.TextBox txtNewPassword
Height = 375
IMEMode = 3 'DISABLE
Left = 2640
PasswordChar = "*"
TabIndex = 6
Top = 2160
Width = 1575
End
Begin VB.TextBox txtPasswordConfirm
Height = 375
IMEMode = 3 'DISABLE
Left = 2640
PasswordChar = "*"
TabIndex = 5
Top = 3000
Width = 1575
End
Begin VB.TextBox txtName
Height = 375
Left = 2640
TabIndex = 4
Top = 480
Width = 1575
End
Begin VB.Label Label4
Caption = "原密码"
Height = 375
Left = 720
TabIndex = 3
Top = 1320
Width = 1335
End
Begin VB.Label Label3
Caption = "新密码"
Height = 375
Left = 720
TabIndex = 2
Top = 2160
Width = 1335
End
Begin VB.Label Label2
Caption = "确认新密码"
Height = 375
Left = 720
TabIndex = 1
Top = 3000
Width = 1335
End
Begin VB.Label Label1
Caption = "用户名"
Height = 375
Left = 720
TabIndex = 0
Top = 480
Width = 1335
End
End
Attribute VB_Name = "frmUserUpdate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim conn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim N As Boolean
N = True
If Trim(txtName.Text) = "" Then
MsgBox "用户名不能为空", vbOKOnly + vbExclamation, ""
txtName.SetFocus
N = False
End If
If Trim(txtOldPassword.Text) = "" Then
MsgBox "原密码不能为空", vbOKOnly + vbExclamation, ""
txtOldPassword.SetFocus
N = False
End If
If N = True Then
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=book.mdb;Persist Security Info=False"
conn.Open
sql = "select*from UserInfo where Username = '"
sql = sql + txtName.Text + "' and Password='" + txtOldPassword.Text + "'"
Set rs = conn.Execute(sql)
If rs.EOF Or rs.BOF Then
MsgBox "用户名或口令错误,请检查!"
N = False
ElseIf N = True Then
If Trim(txtNewPassword.Text) = "" Then
MsgBox "新密码不能为空", vbOKOnly + vbExclamation, ""
txtNewPassword.SetFocus
N = False
End If
If Trim(txtNewPassword.Text <> txtPasswordConfirm) Then
MsgBox "新密码不一致", vbOKOnly + vbExclamation, ""
txtNewPassword.Text = ""
txtPasswordConfirm.Text = ""
N = False
End If
rs.Close
End If
If N = True Then
rs.Open sql, conn, adOpenKeyset, adLockPessimistic
rs.Fields(2) = txtNewPassword.Text
rs.Update
rs.Close
MsgBox "修改用户成功!"
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -