📄 frmuser.frm
字号:
VERSION 5.00
Begin VB.Form frmUser
BorderStyle = 3 'Fixed Dialog
Caption = "Form1"
ClientHeight = 3255
ClientLeft = 45
ClientTop = 330
ClientWidth = 4800
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3255
ScaleWidth = 4800
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command4
Caption = "列表"
Height = 375
Left = 3480
TabIndex = 17
Top = 1680
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "关闭"
Height = 375
Left = 3480
TabIndex = 16
Top = 2160
Width = 1095
End
Begin VB.CommandButton Command2
Caption = ">|"
Height = 375
Index = 3
Left = 3480
TabIndex = 15
Top = 2760
Width = 975
End
Begin VB.CommandButton Command2
Caption = ">"
Height = 375
Index = 2
Left = 2400
TabIndex = 14
Top = 2760
Width = 975
End
Begin VB.CommandButton Command2
Caption = "<"
Height = 375
Index = 1
Left = 1320
TabIndex = 13
Top = 2760
Width = 975
End
Begin VB.CommandButton Command2
Caption = "|<"
Height = 375
Index = 0
Left = 240
TabIndex = 12
Top = 2760
Width = 975
End
Begin VB.CommandButton Command1
Caption = "删除"
Height = 375
Index = 2
Left = 3480
TabIndex = 11
Top = 1200
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "修改"
Height = 375
Index = 1
Left = 3480
TabIndex = 10
Top = 720
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "新建"
Height = 375
Index = 0
Left = 3480
TabIndex = 9
Top = 240
Width = 1095
End
Begin VB.Frame Frame1
Height = 2415
Left = 240
TabIndex = 0
Top = 120
Width = 3015
Begin VB.TextBox Text4
Height = 375
Left = 1320
Locked = -1 'True
TabIndex = 8
Text = "Text4"
Top = 1800
Width = 1455
End
Begin VB.TextBox Text3
Height = 375
Left = 1320
Locked = -1 'True
TabIndex = 7
Text = "Text3"
Top = 1320
Width = 1455
End
Begin VB.TextBox Text2
Height = 375
Left = 1320
Locked = -1 'True
TabIndex = 6
Text = "Text2"
Top = 840
Width = 1455
End
Begin VB.TextBox Text1
Height = 375
Left = 1320
Locked = -1 'True
TabIndex = 5
Text = "Text1"
Top = 360
Width = 1215
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "密码:"
Height = 180
Left = 420
TabIndex = 4
Top = 1920
Width = 540
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "呢称:"
Height = 180
Left = 420
TabIndex = 3
Top = 1440
Width = 540
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "用户名:"
Height = 180
Left = 240
TabIndex = 2
Top = 960
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用户ID:"
Height = 180
Left = 240
TabIndex = 1
Top = 480
Width = 720
End
End
End
Attribute VB_Name = "frmUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public flag As Boolean
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
If Command1(0).Caption = "新建" Then
Text1.Locked = False
Text2.Locked = False
Text3.Locked = False
Text4.Locked = False
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Command1(0).Caption = "保存"
Command1(1).Caption = "取消"
Command1(2).Enabled = False
Command3.Enabled = False
For i = 0 To 3
Command2(i).Enabled = False
Next i
g_DBRset.AddNew
Else
If Trim(Text2.Text) = "" Then
MsgBox "用户名不能空!", vbOKOnly, "提示"
Exit Sub
End If
g_DBRset.Fields.Item("用户名").Value = Text2.Text
g_DBRset.Fields.Item("呢称").Value = Text3.Text
g_DBRset.Fields.Item("密码").Value = Text4.Text
g_DBRset.Update
Command1(0).Caption = "新建"
Command1(1).Caption = "修改"
Command1(2).Enabled = True
Command3.Enabled = True
For i = 0 To 3
Command2(i).Enabled = True
Next i
Text1.Locked = True
Text2.Locked = True
Text3.Locked = True
Text4.Locked = True
End If
Case 1
If Command1(1).Caption = "取消" Then
g_DBRset.CancelUpdate
Command1(0).Caption = "新建"
Command1(1).Caption = "修改"
Command1(2).Enabled = True
Command3.Enabled = True
For i = 0 To 3
Command2(i).Enabled = True
Next i
Text1.Locked = True
Text2.Locked = True
Text3.Locked = True
Text4.Locked = True
Call ShowData
Else
Text1.Locked = False
Text2.Locked = False
Text3.Locked = False
Text4.Locked = False
Command1(0).Caption = "保存"
Command1(1).Caption = "取消"
Command1(2).Enabled = False
Command3.Enabled = False
For i = 0 To 3
Command2(i).Enabled = False
Next i
End If
Case 2
If MsgBox("你真的删除吗?", vbYesNo, "提示") = vbYes Then
g_DBRset.Delete
g_DBRset.MoveNext
If g_DBRset.EOF Then
g_DBRset.MovePrevious
End If
Call ShowData
End If
End Select
End Sub
Private Sub Command2_Click(Index As Integer)
'四个记录指针移动按钮的代码。
On Error GoTo eabc
Select Case Index
Case 0 '第一条
g_DBRset.MoveFirst
Case 1 '上一条
g_DBRset.MovePrevious
Case 2 '下一条
g_DBRset.MoveNext
Case 3 '最后一条
g_DBRset.MoveLast
End Select
Call ShowData '显示
Exit Sub
eabc:
MsgBox "记录指针已到" & IIf(Index = 1, "表头!", "表尾!"), vbOKOnly + vbExclamation, "神龙提示"
If Index = 1 Then
g_DBRset.MoveFirst
Else
g_DBRset.MoveLast
End If
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Command4_Click()
frmUserList.Show 1
End Sub
Private Sub Form_Load()
Me.Caption = "用户管理"
flag = False
' If ConnectToServer() Then
' g_DBRset.Open "user表", g_DBCon, adOpenStatic, adLockOptimistic
Call ShowData '显示第一条记录内容
' flag = True
' End If
End Sub
Private Sub ShowData()
Text1.Text = g_DBRset.Fields.Item(0).Value
Text2.Text = g_DBRset.Fields.Item(1).Value
Text3.Text = g_DBRset.Fields.Item("呢称").Value
Text4.Text = g_DBRset.Fields.Item("密码").Value
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -