📄 form1.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5760
ClientLeft = 60
ClientTop = 450
ClientWidth = 6855
LinkTopic = "Form1"
ScaleHeight = 5760
ScaleWidth = 6855
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text6
DataField = "au_fname"
DataSource = "Adodc1"
Height = 315
Left = 4620
TabIndex = 20
Text = "Text6"
Top = 1560
Width = 1995
End
Begin VB.TextBox Text5
DataField = "contract"
DataSource = "Adodc1"
Height = 315
Left = 1380
TabIndex = 19
Text = "Text5"
Top = 2880
Width = 1995
End
Begin VB.TextBox Text4
DataField = "address"
DataSource = "Adodc1"
Height = 315
Left = 1380
TabIndex = 17
Text = "Text4"
Top = 2400
Width = 1995
End
Begin VB.TextBox Text3
DataField = "phone"
DataSource = "Adodc1"
Height = 315
Left = 1380
TabIndex = 16
Text = "Text3"
Top = 1920
Width = 1995
End
Begin VB.TextBox Text2
DataField = "au_lname"
DataSource = "Adodc1"
Height = 315
Left = 1380
TabIndex = 15
Text = "Text2"
Top = 1500
Width = 1995
End
Begin VB.TextBox Text1
DataField = "au_id"
DataSource = "Adodc1"
Height = 315
Left = 1380
TabIndex = 14
Text = "Text1"
Top = 1080
Width = 1995
End
Begin VB.CommandButton Command9
Caption = "尾记录"
Height = 555
Left = 4020
TabIndex = 9
Top = 4140
Width = 1275
End
Begin VB.CommandButton Command8
Caption = "后一条"
Height = 555
Left = 2760
TabIndex = 8
Top = 4140
Width = 1275
End
Begin VB.CommandButton Command7
Caption = "前一条"
Height = 555
Left = 1500
TabIndex = 7
Top = 4140
Width = 1275
End
Begin VB.CommandButton Command6
Caption = "首记录"
Height = 555
Left = 240
TabIndex = 6
Top = 4140
Width = 1275
End
Begin VB.CommandButton Command5
Caption = "取消"
Height = 555
Left = 5280
TabIndex = 5
Top = 3540
Width = 1275
End
Begin VB.CommandButton Command4
Caption = "保存"
Height = 555
Left = 4020
TabIndex = 4
Top = 3540
Width = 1275
End
Begin VB.CommandButton Command3
Caption = "修改"
Height = 555
Left = 2760
TabIndex = 3
Top = 3540
Width = 1275
End
Begin VB.CommandButton Command2
Caption = "删除"
Height = 555
Left = 1500
TabIndex = 2
Top = 3540
Width = 1275
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 555
Left = 240
TabIndex = 1
Top = 3540
Width = 1275
End
Begin MSAdodcLib.Adodc Adodc1
Height = 555
Left = 720
Top = 5040
Width = 4935
_ExtentX = 8705
_ExtentY = 979
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= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\zp\桌面\authors.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\zp\桌面\authors.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "authors"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "作者名:"
Height = 195
Left = 3480
TabIndex = 21
Top = 1620
Width = 720
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "是否出书:"
Height = 195
Left = 240
TabIndex = 18
Top = 2880
Width = 900
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "作者地址:"
Height = 195
Left = 240
TabIndex = 13
Top = 2460
Width = 900
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "作者电话:"
Height = 195
Left = 240
TabIndex = 12
Top = 1980
Width = 900
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "作者姓:"
Height = 195
Left = 240
TabIndex = 11
Top = 1560
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "作者编号:"
Height = 195
Left = 240
TabIndex = 10
Top = 1140
Width = 900
End
Begin VB.Label Label1
Caption = $"Form1.frx":0000
Height = 795
Left = 660
TabIndex = 0
Top = 120
Width = 5415
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
'调用AddNew方法增加记录
Adodc1.Recordset.AddNew
'在调用AddNew以后,文本框控件处于添加模式,因此
'为了防止程序出错,需要屏蔽其他按钮的使用
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command4.Enabled = True
Command5.Enabled = True
End Sub
Private Sub Command2_Click()
Dim Ans As Integer
'调用delete方法删除记录
'在删除记录之前,最好对用户有一个警告
Ans = MsgBox("确定删除嘛?", vbYesNo, "警告")
If Ans = vbYes Then
Adodc1.Recordset.Delete
End If
End Sub
Private Sub Command3_Click()
'调用AddNew方法增加记录
'Adodc1.Recordset.
'在调用AddNew以后,文本框控件处于添加模式,因此
'为了防止程序出错,需要屏蔽其他按钮的使用
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
End Sub
End Sub
Private Sub Command4_Click()
'通过Update方法保存数据
Adodc1.Recordset.Update
'恢复其他控件的属性
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
'同时使保存和取消按钮失效
Command4.Enabled = False
Command5.Enabled = False
End Sub
Private Sub Command5_Click()
'通过CancelUpdate方法保存数据
Adodc1.Recordset.CancelUpdate
'恢复其他控件的属性
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
'同时使保存和取消按钮失效
Command4.Enabled = False
Command5.Enabled = False
End Sub
Private Sub Command6_Click()
'调用MoveFirst
Adodc1.Recordset.MoveFirst
End Sub
Private Sub Command7_Click()
'移动记录到下一条的方法是MovePrevious
'在调用MovePrevious方法之前,首先需要判断,当前是不是已经到了最前面
'判断方法是调用BOF属性,如果BOF为真,则表示一定到了最前,不能移动
'否则会出错
If Not Adodc1.Recordset.BOF Then
Adodc1.Recordset.MovePrevious
Else '如果为真,则移动到最后一条记录
Adodc1.Recordset.MoveFirst
End If
End Sub
Private Sub Command8_Click()
'移动记录到下一条的方法是MoveNext
'在调用MoveNext方法之前,首先需要判断,当前是不是已经到了最后
'判断方法是调用EOF属性,如果EOF为真,则表示一定到了最后,不能移动
'否则会出错
If Not Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveNext
Else '如果为真,则移动到最后一条记录
Adodc1.Recordset.MoveLast
End If
End Sub
Private Sub Command9_Click()
'调用MoveLast
Adodc1.Recordset.MoveLast
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -