📄 form1.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5925
ClientLeft = 60
ClientTop = 345
ClientWidth = 6915
LinkTopic = "Form1"
ScaleHeight = 5925
ScaleWidth = 6915
StartUpPosition = 3 '窗口缺省
Begin MSComctlLib.ImageList ImageList1
Left = 5520
Top = 0
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 4
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0000
Key = "db"
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0452
Key = "dbt"
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":08A4
Key = "field"
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0CF6
Key = "tab"
EndProperty
EndProperty
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 4440
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox Text1
Height = 300
Left = 4080
TabIndex = 7
Top = 2640
Width = 1575
End
Begin VB.CommandButton Command6
Caption = "退出"
Height = 375
Left = 4080
TabIndex = 6
Top = 5400
Width = 2655
End
Begin VB.CommandButton Command4
Caption = "确定"
Height = 375
Left = 5760
TabIndex = 5
Top = 2610
Width = 975
End
Begin VB.CommandButton Command3
Caption = "新建表"
Height = 375
Left = 4080
TabIndex = 4
Top = 1680
Width = 2655
End
Begin VB.CommandButton Command2
Caption = "打开数据库"
Height = 375
Left = 4080
TabIndex = 3
Top = 1200
Width = 2655
End
Begin VB.CommandButton Command1
Caption = "新建数据库"
Height = 375
Left = 4080
TabIndex = 2
Top = 720
Width = 2655
End
Begin MSComctlLib.TreeView TreeView1
Height = 5055
Left = 120
TabIndex = 1
Top = 720
Width = 3735
_ExtentX = 6588
_ExtentY = 8916
_Version = 393217
Style = 7
ImageList = "ImageList1"
Appearance = 1
End
Begin VB.Frame Frame1
Caption = "添加字段"
Height = 2175
Left = 4080
TabIndex = 9
Top = 3120
Visible = 0 'False
Width = 2655
Begin VB.ComboBox Combo1
Height = 300
Left = 840
TabIndex = 13
Text = "Combo1"
Top = 720
Width = 1695
End
Begin VB.TextBox Text3
Height = 300
Left = 840
TabIndex = 12
Top = 1200
Visible = 0 'False
Width = 1695
End
Begin VB.TextBox Text2
Height = 300
Left = 840
TabIndex = 11
Top = 240
Width = 1695
End
Begin VB.CommandButton Command5
Caption = "添加字段"
Height = 375
Left = 840
TabIndex = 10
Top = 1560
Visible = 0 'False
Width = 1215
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "长度:"
Height = 180
Left = 120
TabIndex = 16
Top = 1260
Visible = 0 'False
Width = 540
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "类型:"
Height = 180
Left = 120
TabIndex = 15
Top = 780
Width = 540
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "名称:"
Height = 180
Left = 120
TabIndex = 14
Top = 300
Width = 540
End
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "输入表名称:"
Height = 180
Left = 4080
TabIndex = 8
Top = 2280
Width = 1080
End
Begin VB.Label Label1
Caption = "创建数据库"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2400
TabIndex = 0
Top = 120
Width = 2175
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()
'新建数据库时出现输入数据库名对话框
CommonDialog1.DialogTitle = "请输入数据库名"
CommonDialog1.Filter = "Access 数据库(*.mdb) | *.mdb"
CommonDialog1.ShowSave
If CommonDialog1.FileTitle <> "" Then
dbnum = dbnum + 1
'新建数据库
Set newdatabase = Workspaces(0).CreateDatabase(CommonDialog1.FileName, _
dbLangGeneral, dbversion70)
'添加节点
Set nod = TreeView1.Nodes.Add("dba", tvwChild, "db" + Str(dbnum), _
Left(CommonDialog1.FileTitle, Len(CommonDialog1.FileTitle) - 4), "db")
nod.EnsureVisible
End Sub
Private Sub Command2_Click()
'打开数据库
Dim tabledf As TableDefs
Dim fielddf As Fields
CommonDialog1.DialogTitle = "请选择数据库名"
CommonDialog1.Filter = "Access数据库 (*.mdb) | *.mdb"
CommonDialog1.ShowOpen
If CommonDialog1.FileTitle <> "" Then
dbnum = dbnum + 1
'打开数据库
Set newdatabase = Workspaces(0).OpenDatabase(CommonDialog1.FileName)
Set nod = TreeView1.Nodes.Add("dba", tvwChild, "db" + Str(dbnum), _
Left(CommonDialog1.FileTitle, Len(CommonDialog1.FileTitle) - 4), "db")
nod.EnsureVisible
'打开表
If newdatabase.TableDefs.Count > 0 Then
Set tabledf = newdatabase.TableDefs
For Each newtable In tabledf
tablenum = tablenum + 1
Set nodtab = TreeView1.Nodes.Add("db" + Str(num), _
tvwChild, "dbt" + Str(tablenum), newtable.Name, "tab")
'打开字段
If newtable.Fields.Count > 0 Then
sfnum = sfnum + 1
Set nodsumf = TreeView1.Nodes.Add("dbt" + Str(tablenum), _
tvwChild, "dbsf" + Str(sfnum), "字段", "field")
Set fielddf = newtable.Fields
For Each newfield In fielddf
fieldnum = fieldnum + 1
Set nodfield = TreeView1.Nodes.Add("dbsf" + Str(sfnum), _
tvwChild, "dbf" + Str(fieldnum), nwefield.Name, "field")
Next
End If
Next
End If
End If
End Sub
Private Sub Command3_Click()
'新建表
Label5.Visible = True
Text3.Visible = True
Command5.Visible = True
Text3.SetFocus
End Sub
Private Sub Command4_Click()
'当新建表而且Text3中有信息时产生新表
If Text3.Text <> "" Then
Frame1.Visible = True
Set newtable = newdatabase.CreateTableDef(Text3.Text)
appnewtab = 1
tablenum = tablenum + 1
Set nodtab = TreeView1.Nodes.Add("db" + Str(dbnum), tvwChild, _
"dbt" + Str(tablenum), Text3.Text, "tab")
nodtab.EnsureVisible
End If
End Sub
Private Sub Command5_Click()
'新建字段
If Text1.Text <> "" Then
'当不需输入字节数时
If Text2.Enabled = False Then
Set newfield = newtable.CreateField(Text1.Text, ftype)
Else
Set nwefield = newtable.CreateField(Text1.Text, ftype, CInt(Text2.Text))
End If
'把字段添加到表中
newtable.Fields.Append newfield
'更新数据库
If appnewtab = 1 Then
newdatabase.TableDefs.Append newtable
appnewtab = 0
End If
'添加“字段”节点
If nodtab.Children = 0 Then
sfnum = sfnum + 1
Set nodsumf = TreeView1.Nodes.Add("dbt" + Str(tablenum), tvwChild, _
"dbsf" + Str(sfnum), "字段", "field")
End If
fieldnum = fieldnum + 1
Set nodfield = TreeView1.Nodes.Add("dbsf" + Str(sfnum), tvwChild, _
"dbf" + Str(fieldnum), Text1.Text, "field")
nodfield.EnsureVisible
End If
End Sub
Private Sub Command6_Click()
Unload Me
End Sub
Private Sub Form_Load()
Combo1.AddItem "Boolean"
Combo1.AddItem "Byte"
Combo1.AddItem "Integer"
Combo1.AddItem "Long"
Combo1.AddItem "Currency"
Combo1.AddItem "Single"
Combo1.AddItem "Double"
Combo1.AddItem "Date/Time"
Combo1.AddItem "Text"
Combo1.AddItem "Binary"
Set nod = TreeView1.Nodes.Add(, , "dba", "数据库", "db")
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -