📄 formadd.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form formadd
BorderStyle = 3 'Fixed Dialog
Caption = "添加记录"
ClientHeight = 3195
ClientLeft = 45
ClientTop = 330
ClientWidth = 4740
Icon = "FORMADD.frx":0000
LinkTopic = "Form3"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4740
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Visible = 0 'False
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 195
Top = 3375
Width = 4200
_ExtentX = 7408
_ExtentY = 582
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 TabDlg.SSTab SSTab1
Height = 3135
Left = 0
TabIndex = 0
Top = 0
Width = 4695
_ExtentX = 8281
_ExtentY = 5530
_Version = 393216
Tabs = 2
TabsPerRow = 2
TabHeight = 520
TabCaption(0) = "书籍记录"
TabPicture(0) = "FORMADD.frx":0CCA
Tab(0).ControlEnabled= -1 'True
Tab(0).Control(0)= "Label6"
Tab(0).Control(0).Enabled= 0 'False
Tab(0).Control(1)= "Label5"
Tab(0).Control(1).Enabled= 0 'False
Tab(0).Control(2)= "Label3"
Tab(0).Control(2).Enabled= 0 'False
Tab(0).Control(3)= "Label2"
Tab(0).Control(3).Enabled= 0 'False
Tab(0).Control(4)= "Label1"
Tab(0).Control(4).Enabled= 0 'False
Tab(0).Control(5)= "Command2"
Tab(0).Control(5).Enabled= 0 'False
Tab(0).Control(6)= "Command1"
Tab(0).Control(6).Enabled= 0 'False
Tab(0).Control(7)= "Text4"
Tab(0).Control(7).Enabled= 0 'False
Tab(0).Control(8)= "Text5"
Tab(0).Control(8).Enabled= 0 'False
Tab(0).Control(9)= "Combo1"
Tab(0).Control(9).Enabled= 0 'False
Tab(0).Control(10)= "Text3"
Tab(0).Control(10).Enabled= 0 'False
Tab(0).Control(11)= "Text2"
Tab(0).Control(11).Enabled= 0 'False
Tab(0).Control(12)= "Text1"
Tab(0).Control(12).Enabled= 0 'False
Tab(0).ControlCount= 13
TabCaption(1) = "学生记录"
TabPicture(1) = "FORMADD.frx":0CE6
Tab(1).ControlEnabled= 0 'False
Tab(1).Control(0)= "Label10"
Tab(1).Control(0).Enabled= 0 'False
Tab(1).Control(1)= "Label9"
Tab(1).Control(1).Enabled= 0 'False
Tab(1).Control(2)= "Label8"
Tab(1).Control(2).Enabled= 0 'False
Tab(1).Control(3)= "Label7"
Tab(1).Control(3).Enabled= 0 'False
Tab(1).Control(4)= "Text8"
Tab(1).Control(4).Enabled= 0 'False
Tab(1).Control(5)= "Combo2"
Tab(1).Control(5).Enabled= 0 'False
Tab(1).Control(6)= "Text7"
Tab(1).Control(6).Enabled= 0 'False
Tab(1).Control(7)= "Text6"
Tab(1).Control(7).Enabled= 0 'False
Tab(1).Control(8)= "Command4"
Tab(1).Control(8).Enabled= 0 'False
Tab(1).Control(9)= "Command3"
Tab(1).Control(9).Enabled= 0 'False
Tab(1).ControlCount= 10
Begin VB.CommandButton Command3
Caption = "离开"
Height = 390
Left = -72390
TabIndex = 19
Top = 2550
Width = 1455
End
Begin VB.CommandButton Command4
Caption = "添加"
Height = 390
Left = -74340
TabIndex = 18
Top = 2565
Width = 1455
End
Begin VB.TextBox Text6
Enabled = 0 'False
Height = 285
Left = -73710
TabIndex = 17
Top = 510
Width = 3105
End
Begin VB.TextBox Text7
Height = 285
Left = -73725
TabIndex = 16
Top = 930
Width = 3120
End
Begin VB.ComboBox Combo2
Height = 315
ItemData = "FORMADD.frx":0D02
Left = -73725
List = "FORMADD.frx":0D21
TabIndex = 15
Top = 1380
Width = 3150
End
Begin VB.TextBox Text8
Height = 450
Left = -73725
MaxLength = 50
TabIndex = 14
Top = 1815
Width = 3135
End
Begin VB.TextBox Text1
Enabled = 0 'False
Height = 285
Left = 1200
TabIndex = 8
Top = 510
Width = 3195
End
Begin VB.TextBox Text2
Height = 285
Left = 885
TabIndex = 7
Top = 945
Width = 3495
End
Begin VB.TextBox Text3
Height = 285
Left = 900
TabIndex = 6
Top = 1320
Width = 1350
End
Begin VB.ComboBox Combo1
Height = 315
ItemData = "FORMADD.frx":0D83
Left = 2865
List = "FORMADD.frx":0D96
TabIndex = 5
Top = 1305
Width = 1515
End
Begin VB.TextBox Text5
Height = 285
Left = 885
MaxLength = 50
TabIndex = 4
Top = 2115
Width = 3525
End
Begin VB.TextBox Text4
Height = 285
Left = 885
TabIndex = 3
Top = 1710
Width = 3510
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 390
Left = 660
TabIndex = 2
Top = 2565
Width = 1455
End
Begin VB.CommandButton Command2
Caption = "离开"
Height = 390
Left = 2610
TabIndex = 1
Top = 2550
Width = 1455
End
Begin VB.Label Label7
Caption = "自动编号:"
Height = 195
Left = -74775
TabIndex = 23
Top = 555
Width = 915
End
Begin VB.Label Label8
Caption = "姓 名"
Height = 240
Left = -74760
TabIndex = 22
Top = 975
Width = 900
End
Begin VB.Label Label9
Caption = "单 位"
Height = 240
Left = -74775
TabIndex = 21
Top = 1440
Width = 945
End
Begin VB.Label Label10
Caption = "备 注"
Height = 225
Left = -74775
TabIndex = 20
Top = 1905
Width = 915
End
Begin VB.Label Label1
Caption = "自动编号:"
Height = 255
Left = 255
TabIndex = 13
Top = 555
Width = 1095
End
Begin VB.Label Label2
Caption = "书 名"
Height = 210
Left = 300
TabIndex = 12
Top = 975
Width = 885
End
Begin VB.Label Label3
BackColor = &H80000004&
Caption = "作 者"
Height = 255
Left = 330
TabIndex = 11
Top = 1365
Width = 465
End
Begin VB.Label Label5
Caption = "出版社"
Height = 270
Left = 315
TabIndex = 10
Top = 1785
Width = 705
End
Begin VB.Label Label6
Caption = "简 介"
Height = 210
Left = 330
TabIndex = 9
Top = 2175
Width = 450
End
End
End
Attribute VB_Name = "formadd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'**********************************
'添加记录窗体
'************************************
'所调用的API函数,自定义过程,类型,常数请参阅相应模块
Option Explicit
'Dim rcdset As Recordset '窗体级变量,存放ADO控件的当前记录
'**************窗体事件*********
'窗体加载
Private Sub Form_Load()
loadmdb Adodc1 '连接数据库
Text1.Text = autobooknum(Adodc1, "书籍总表") '获得书籍自动编号
Text6.Text = autostudentnum(Adodc1, "学生总表") '获得学生自动编号
End Sub
'*************添加数据******************
'书籍记录
Private Sub Command1_Click()
'判断各个字段值是否合法,符合条件添加记录
If Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Combo1.Text = "" Then
MsgBox "请完整输入必要字段,简介可以不填。"
Exit Sub
Else
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "书籍总表"
Adodc1.Refresh
Set rcdset = Adodc1.Recordset
rcdset.AddNew
rcdset!书号 = Text1.Text
rcdset!书名 = Text2.Text
rcdset!作者 = Text3.Text
rcdset!类别 = Combo1.Text
rcdset!出版社 = Text4.Text
rcdset!简介 = Text5.Text
rcdset.Update
Adodc1.Refresh
Formmain.DataGrid1.Refresh
MsgBox "记录已添加。"
Text1.Text = Right(Str(Val(Text1.Text) + 1), Len(Str(Val(Text1.Text) + 1)) - 1) '获得新的编号,去掉了字符前的一个空格
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Combo1.Text = ""
End If
End Sub
'学生记录
Private Sub Command4_Click()
'判断各个字段值是否合法,符合条件添加记录
If Text7.Text = "" Or Combo2.Text = "" Then
MsgBox "请完整输入必要字段,备注可以不填。"
Exit Sub
Else
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "学生总表"
Adodc1.Refresh
Set rcdset = Adodc1.Recordset
rcdset.AddNew
rcdset!学号 = Text6.Text
rcdset!姓名 = Text7.Text
rcdset!单位 = Combo2.Text
rcdset!备注 = Text8.Text
rcdset.Update
Adodc1.Refresh
Formmain.DataGrid1.Refresh
MsgBox "记录已添加。"
Text6.Text = Right(Str(Val(Text6.Text) + 1), Len(Str(Val(Text6.Text) + 1)) - 1) '获得新的编号,去掉了字符前的一个空格
Text7.Text = ""
Text8.Text = ""
Combo2.Text = ""
End If
End Sub
'*************其他******************
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -