📄 useradd.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form useradd
BorderStyle = 4 'Fixed ToolWindow
Caption = "添加用户"
ClientHeight = 4050
ClientLeft = 45
ClientTop = 285
ClientWidth = 4530
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4050
ScaleWidth = 4530
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 2760
Top = 3480
Visible = 0 'False
Width = 1455
_ExtentX = 2566
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
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.Frame Frame4
Height = 3975
Left = 3000
TabIndex = 13
Top = 0
Width = 1455
Begin VB.CommandButton Command6
Caption = "下一条"
Height = 375
Left = 240
TabIndex = 19
Top = 960
Width = 975
End
Begin VB.CommandButton Command5
Caption = "上一条"
Height = 375
Left = 240
TabIndex = 18
Top = 360
Width = 975
End
Begin VB.CommandButton Command4
Caption = "退出"
Height = 375
Left = 240
TabIndex = 17
Top = 3360
Width = 975
End
Begin VB.CommandButton Command3
Caption = "编辑"
Height = 375
Left = 240
TabIndex = 16
Top = 2760
Width = 975
End
Begin VB.CommandButton Command2
Caption = "删除"
Height = 375
Left = 240
TabIndex = 15
Top = 2160
Width = 975
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 240
TabIndex = 14
Top = 1560
Width = 975
End
End
Begin VB.Frame Frame1
Height = 3975
Left = 0
TabIndex = 0
Top = 0
Width = 2895
Begin VB.Frame Frame3
Height = 2895
Left = 120
TabIndex = 4
Top = 960
Width = 2655
Begin VB.TextBox Text4
DataField = "级别"
DataSource = "Adodc1"
Enabled = 0 'False
Height = 300
Left = 1320
TabIndex = 12
Top = 2250
Width = 975
End
Begin VB.TextBox Text3
DataField = "pass"
DataSource = "Adodc1"
Enabled = 0 'False
Height = 300
IMEMode = 3 'DISABLE
Left = 1320
PasswordChar = "*"
TabIndex = 11
Top = 1530
Width = 975
End
Begin VB.TextBox Text2
Enabled = 0 'False
Height = 300
IMEMode = 3 'DISABLE
Left = 1320
PasswordChar = "*"
TabIndex = 10
Top = 920
Width = 975
End
Begin VB.TextBox Text1
DataField = "用户"
DataSource = "Adodc1"
Enabled = 0 'False
Height = 300
Left = 1320
TabIndex = 9
Top = 320
Width = 975
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "用户级别:"
Height = 180
Left = 240
TabIndex = 8
Top = 2280
Width = 900
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "确认密码:"
Height = 180
Left = 240
TabIndex = 7
Top = 1560
Width = 900
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "密码:"
Height = 180
Left = 240
TabIndex = 6
Top = 960
Width = 540
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用户名:"
Height = 180
Left = 240
TabIndex = 5
Top = 360
Width = 720
End
End
Begin VB.Frame Frame2
Height = 615
Left = 120
TabIndex = 1
Top = 240
Width = 2655
Begin VB.OptionButton Option2
Caption = "普通用户"
Height = 255
Left = 1440
TabIndex = 3
Top = 240
Width = 1095
End
Begin VB.OptionButton Option1
Caption = "管理员"
Height = 255
Left = 240
TabIndex = 2
Top = 240
Width = 975
End
End
End
End
Attribute VB_Name = "useradd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
On Error Resume Next
If Command1.Caption = "添加" Then
Command2.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command1.Caption = "确定"
Command3.Caption = "取消"
Adodc1.Recordset.AddNew
Option1.Enabled = True
Option2.Enabled = True
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text2.Text = ""
ElseIf Text1.Text = "" Then
MsgBox "用户名不能为空!", 48, "提示"
ElseIf Text2.Text = "" Then
MsgBox "密码不能为空!", 48, "提示"
ElseIf Text2.Text <> Text3.Text Then
MsgBox "密码两次需一致!", 48, "提示"
ElseIf Text4.Text = "" Then
MsgBox "请选择所建用户类型!", 48, "提示"
Else
Command2.Enabled = True
Command3.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command3.Caption = "编辑"
Command1.Caption = "添加"
Adodc1.Recordset.Update
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Option1.Value = False
Option2.Value = False
Option1.Enabled = False
Option2.Enabled = False
End If
End Sub
Private Sub Command2_Click()
On Error Resume Next
If Adodc1.Recordset.RecordCount = 1 Then
Command2.Enabled = False
End If
If (MsgBox("你真的想删除当前记录吗?", vbOKCancel, "系统提示")) = vbOK Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveFirst
Adodc1.Refresh
End If
End Sub
Private Sub Command3_Click()
On Error Resume Next
If Command3.Caption = "编辑" Then
Command2.Enabled = False
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Option1.Enabled = True
Option2.Enabled = True
Command1.Caption = "确定"
ElseIf Command3.Caption = "取消" Then
Command3.Caption = "编辑"
Command1.Caption = "添加"
Command2.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Text2.Text = Text3.Text
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Option1.Value = False
Option2.Value = False
Option1.Enabled = False
Option2.Enabled = False
Adodc1.Recordset.CancelUpdate
End If
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Command5_Click()
Adodc1.Recordset.MovePrevious '移动记录
Command6.Enabled = True
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
Command5.Enabled = False
End If
Text2.Text = Text3.Text
End Sub
Private Sub Command6_Click()
Adodc1.Recordset.MoveNext '移动记录
Command5.Enabled = True
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
Command6.Enabled = False
End If
Text2.Text = Text3.Text
End Sub
Private Sub Form_Load()
Dim provider As String
Dim datasource As String
provider = "provider=Microsoft.jet.oledb.4.0"
datasource = "data source=" & App.Path & "\DB.mdb"
With Adodc1
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "yonghu"
.Refresh
End With
Option1.Enabled = False
Option2.Enabled = False
If Adodc1.Recordset.RecordCount = 0 Then
Command2.Enabled = False
Command3.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
End If
Text2.Text = Text3.Text
End Sub
Private Sub Option1_Click()
Text4.Text = "管理员"
End Sub
Private Sub Option2_Click()
Text4.Text = "普通用户"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -