一个可以在文本中录入数据到ACCESS数据库中的源代码。
源代码在线查看: 数据文件_录入f3.frm
VERSION 5.00
Begin VB.Form frmFile
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "提供路径和文件名"
ClientHeight = 6270
ClientLeft = 60
ClientTop = 345
ClientWidth = 6960
LinkTopic = "Form1"
ScaleHeight = 6270
ScaleWidth = 6960
StartUpPosition = 3 '窗口缺省
Begin VB.CheckBox Check3
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "有列标"
ForeColor = &H80000008&
Height = 375
Left = 2640
TabIndex = 16
Top = 5640
Value = 1 'Checked
Width = 1095
End
Begin VB.CheckBox Check2
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "有行标"
ForeColor = &H80000008&
Height = 375
Left = 1440
TabIndex = 15
Top = 5640
Value = 1 'Checked
Width = 1095
End
Begin VB.CheckBox Check1
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "有标题"
ForeColor = &H80000008&
Height = 375
Left = 240
TabIndex = 14
Top = 5640
Value = 1 'Checked
Width = 1095
End
Begin VB.CommandButton cmdExit
Caption = "退 出"
Height = 375
Left = 5640
TabIndex = 13
ToolTipText = "停止作业,结束程序运行"
Top = 5760
Width = 1095
End
Begin VB.CommandButton cmdOK
Caption = "确 定"
Height = 375
Left = 4440
TabIndex = 12
ToolTipText = "给出文件名后单击"
Top = 5760
Width = 1095
End
Begin VB.TextBox txtFile
Alignment = 2 'Center
Appearance = 0 'Flat
Height = 375
Left = 240
TabIndex = 11
Top = 5040
Width = 6495
End
Begin VB.TextBox txtNew
Alignment = 2 'Center
Appearance = 0 'Flat
Height = 375
Left = 3600
TabIndex = 9
Top = 3960
Width = 2535
End
Begin VB.OptionButton Option2
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "用新文件名"
ForeColor = &H80000008&
Height = 495
Left = 240
TabIndex = 7
Top = 1560
Width = 1695
End
Begin VB.OptionButton Option1
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "用旧文件名(文件将被破坏)"
ForeColor = &H80000008&
Height = 495
Left = 240
TabIndex = 6
Top = 1200
Value = -1 'True
Width = 2775
End
Begin VB.FileListBox File1
Appearance = 0 'Flat
Height = 2010
Left = 240
TabIndex = 2
Top = 2400
Width = 2535
End
Begin VB.DirListBox Dir1
Appearance = 0 'Flat
Height = 3030
Left = 3240
TabIndex = 1
Top = 360
Width = 3495
End
Begin VB.DriveListBox Drive1
Appearance = 0 'Flat
Height = 300
Left = 120
TabIndex = 0
Top = 360
Width = 3015
End
Begin VB.Label Label5
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "数据文件的全名"
ForeColor = &H80000008&
Height = 375
Left = 1680
TabIndex = 10
Top = 4680
Width = 3375
End
Begin VB.Label Label4
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "新文件名(给出简单文件名)"
ForeColor = &H80000008&
Height = 255
Left = 3240
TabIndex = 8
Top = 3720
Width = 3135
End
Begin VB.Label Label3
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "选择数据文件"
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 5
Top = 2160
Width = 2535
End
Begin VB.Label Label2
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "选择目录"
ForeColor = &H80000008&
Height = 255
Left = 3480
TabIndex = 4
Top = 120
Width = 3135
End
Begin VB.Label Label1
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "选择驱动器"
ForeColor = &H80000008&
Height = 255
Left = 120
TabIndex = 3
Top = 120
Width = 2415
End
End
Attribute VB_Name = "frmFile"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'文件窗体
'利用文件控件提供路径和文件名
'设定为启动模块
Option Explicit
Private Sub Form_Load()
Label4.Visible = False '不显示新建文件指示标签
txtNew.Visible = False '不显示容纳新建文件名的文本框
File1.Pattern = "*.dat" '文件列表框只显示数据文件
'缺省设置的文件全名,与应用程序在同一个子目录内
txtFile.Text = App.Path & "\" & "New_Data.dat"
End Sub
'选择目录
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
'选择驱动器
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
'确定文件
Private Sub File1_Click()
txtFile.Text = Dir1.Path & "\" & File1.FileName
End Sub
'选择打开文件
Private Sub Option1_Click()
Label3.Visible = True '显示打开文件指示标签
File1.Visible = True '显示文件控件
Label4.Visible = False '不显示新建文件指示标签
txtNew.Visible = False '不显示容纳新建文件名的文本框
End Sub
'选择新建文件
Private Sub Option2_Click()
Label3.Visible = False '不显示打开文件指示标签
File1.Visible = False '不显示文件控件
Label4.Visible = True '显示新建文件指示标签
txtNew.Visible = True '显示容纳新建文件名的文本框
txtNew.SetFocus '取得焦点
End Sub
'新建文件全名
Private Sub txtNew_Change()
txtFile.Text = Dir1.Path & "\" & txtNew.Text & ".dat"
End Sub
Private Sub Check1_Click()
'确定“标题”的最优先地位
If Check1.Value = 0 Then
Check2.Value = 0
Check3.Value = 0
End If
End Sub
Private Sub Check2_Click()
'确定“行标”的次优先地位
If Check2.Value = 0 Then Check3.Value = 0
If Check2.Value = 1 Then Check1.Value = 1
End Sub
Private Sub Check3_Click()
'确定“列标”的不优先地位
If Check3.Value = 1 Then
Check1.Value = 1
Check2.Value = 1
End If
End Sub
'确定,给出文件名后单击
Private Sub cmdOK_Click()
strFileName = txtFile.Text '文件名
If Check1.Value = 1 Then
blnTitle = True '有标题
Else
blnTitle = False '无标题
End If
If Check2.Value = 1 Then
blnRowLabel = True '有行标
Else
blnRowLabel = False '无行标
End If
If Check3.Value = 1 Then
blnColLabel = True '有列标
Else
blnColLabel = False '无列标
End If
Unload Me
'显示提供行数和列数窗体
frmInputRowCol.Visible = True
End Sub
'退出,结束程序运行
Private Sub cmdExit_Click()
Unload Me
End
End Sub