📄 recfrm.frm
字号:
Begin VB.TextBox Text5
Height = 375
Left = 3960
TabIndex = 21
Text = "0532-2292432"
Top = 1830
Width = 1695
End
Begin VB.TextBox Text1
Height = 375
Left = 960
TabIndex = 18
Text = "一班"
Top = 510
Width = 1695
End
Begin VB.CommandButton Command2
Caption = "保存2"
Height = 375
Left = 5880
TabIndex = 1
Top = 414
Width = 975
End
Begin VB.Image Image1
Height = 480
Left = 4440
MouseIcon = "RecFrm.frx":0016
MousePointer = 99 'Custom
Picture = "RecFrm.frx":0458
ToolTipText = "http://dyqing.533.net"
Top = 0
Width = 480
End
Begin VB.Image Image2
Height = 480
Left = 5040
MouseIcon = "RecFrm.frx":0762
MousePointer = 99 'Custom
Picture = "RecFrm.frx":0BA4
ToolTipText = "duyunqing@163.net"
Top = 0
Width = 480
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "姓名"
Height = 180
Index = 2
Left = 120
TabIndex = 35
Top = 1260
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "性别"
Height = 180
Index = 3
Left = 3120
TabIndex = 34
Top = 1260
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "收费情况"
Height = 180
Index = 10
Left = 120
TabIndex = 30
Top = 4560
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "传呼"
Height = 180
Index = 9
Left = 3120
TabIndex = 28
Top = 3900
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "单位电话"
Height = 180
Index = 8
Left = 120
TabIndex = 26
Top = 3900
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "工作单位"
Height = 180
Index = 7
Left = 120
TabIndex = 23
Top = 3240
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "家庭住址"
Height = 180
Index = 6
Left = 120
TabIndex = 22
Top = 2580
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "联系电话"
Height = 180
Index = 5
Left = 3120
TabIndex = 20
Top = 1920
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "出生日期"
Height = 180
Index = 4
Left = 120
TabIndex = 19
Top = 1920
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "学号"
Height = 180
Index = 1
Left = 3120
TabIndex = 17
Top = 600
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "班级"
Height = 180
Index = 0
Left = 120
TabIndex = 16
Top = 600
Width = 360
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "数据录入时保存的几种方法"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 315
Left = 495
TabIndex = 39
Top = 15
Width = 3780
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "数据录入时保存的几种方法"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 315
Left = 480
TabIndex = 38
Top = 0
Width = 3780
End
End
Attribute VB_Name = "RecFrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'指定链接
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
'第一种方法使用配置好的DATA控件
Data1.Visible = False
Data1.DatabaseName = App.Path & "\db1.mdb"
Data1.RecordSource = "select * from 学生"
Data1.Refresh
With Data1.Recordset
.AddNew
.Fields("班级") = Text1.Text
.Fields("学号") = Text2.Text
.Fields("姓名") = Text3.Text
.Fields("性别") = Combo1.Text
.Fields("出生日期") = MaskEdBox1.Text
.Fields("联系电话") = Text5.Text
.Fields("家庭住址") = Text6.Text
.Fields("工作单位") = Text7.Text
.Fields("单位电话") = Text8.Text
.Fields("传呼") = Text9.Text
.Fields("收费情况") = Text10.Text
.Update
End With
Data1.Refresh
BrwFrm.Show
End Sub
Private Sub Command10_Click()
'第十种方法引用ADODC代码
Dim cnn1 As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim cnnstr As String
cnnstr = " provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & App.Path & "\db1.mdb;"
cnn1.Open cnnstr
With rst
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "学生", cnnstr, , , adCmdTable
'.Open "学生", cnn1, , , adCmdTable
.AddNew
.Fields("班级") = Text1.Text
.Fields("学号") = Text2.Text
.Fields("姓名") = Text3.Text
.Fields("性别") = Combo1.Text
.Fields("出生日期") = MaskEdBox1.Text
.Fields("联系电话") = Text5.Text
.Fields("家庭住址") = Text6.Text
.Fields("工作单位") = Text7.Text
.Fields("单位电话") = Text8.Text
.Fields("传呼") = Text9.Text
.Fields("收费情况") = Text10.Text
.Update
.UpdateBatch adAffectAllChapters
End With
cnn1.Close
BrwFrm.Show
End Sub
Private Sub Command11_Click()
'第十一种方法动态增加DATA控件
RecFrm.Controls.Add "VB.data", "data2"
With RecFrm!Data2
.Visible = False
.DatabaseName = App.Path & "\db1.mdb"
.RecordSource = "select * from 学生"
.Refresh
.Recordset.AddNew
.Recordset.Fields("班级") = Text1.Text
.Recordset.Fields("学号") = Text2.Text
.Recordset.Fields("姓名") = Text3.Text
.Recordset.Fields("性别") = Combo1.Text
.Recordset.Fields("出生日期") = MaskEdBox1.Text
.Recordset.Fields("联系电话") = Text5.Text
.Recordset.Fields("家庭住址") = Text6.Text
.Recordset.Fields("工作单位") = Text7.Text
.Recordset.Fields("单位电话") = Text8.Text
.Recordset.Fields("传呼") = Text9.Text
.Recordset.Fields("收费情况") = Text10.Text
.Recordset.Update
.Refresh
End With
RecFrm.Controls.Remove "data2"
BrwFrm.Show
End Sub
Private Sub Command12_Click()
'第十二种方法动态增加adodc控件
RecFrm.Controls.Add "MSAdodcLib.Adodc", "adodc2"
With RecFrm!Adodc2
.Visible = False
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51; Data Source=" & App.Path & "\db1.mdb;"
.CommandType = adCmdTable
.RecordSource = "学生"
.Refresh
.Recordset.AddNew
.Recordset.Fields("班级") = Text1.Text
.Recordset.Fields("学号") = Text2.Text
.Recordset.Fields("姓名") = Text3.Text
.Recordset.Fields("性别") = Combo1.Text
.Recordset.Fields("出生日期") = MaskEdBox1.Text
.Recordset.Fields("联系电话") = Text5.Text
.Recordset.Fields("家庭住址") = Text6.Text
.Recordset.Fields("工作单位") = Text7.Text
.Recordset.Fields("单位电话") = Text8.Text
.Recordset.Fields("传呼") = Text9.Text
.Recordset.Fields("收费情况") = Text10.Text
.Recordset.Update
End With
RecFrm.Controls.Remove "adodc2"
BrwFrm.Show
End Sub
Private Sub Command13_Click()
'第十三种方法动态增加adodc控件
RecFrm.Controls.Add "MSAdodcLib.Adodc", "adodc2"
With RecFrm!Adodc2
.Visible = False
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51; Data Source=" & App.Path & "\db1.mdb;"
.CommandType = adCmdText
.RecordSource = "SELECT * FROM 学生"
.Refresh
.Recordset.AddNew
.Recordset.Fields("班级") = Text1.Text
.Recordset.Fields("学号") = Text2.Text
.Recordset.Fields("姓名") = Text3.Text
.Recordset.Fields("性别") = Combo1.Text
.Recordset.Fields("出生日期") = MaskEdBox1.Text
.Recordset.Fields("联系电话") = Text5.Text
.Recordset.Fields("家庭住址") = Text6.Text
.Recordset.Fields("工作单位") = Text7.Text
.Recordset.Fields("单位电话") = Text8.Text
.Recordset.Fields("传呼") = Text9.Text
.Recordset.Fields("收费情况") = Text10.Text
.Recordset.Update
End With
RecFrm.Controls.Remove "adodc2"
BrwFrm.Show
End Sub
Private Sub Command14_Click()
'第十四种方法动态增加DATA控件
RecFrm.Controls.Add "VB.data", "data2"
With RecFrm!Data2
.Visible = False
.DatabaseName = App.Path & "\db1.mdb"
.RecordSource = "学生"
.Refresh
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -