?? form1.frm
字號:
VERSION 5.00
Begin VB.Form Form1
Caption = "演示數據庫操作"
ClientHeight = 5835
ClientLeft = 60
ClientTop = 345
ClientWidth = 11880
LinkTopic = "Form1"
ScaleHeight = 5835
ScaleWidth = 11880
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame4
Caption = "添加/刪除現有表的字段"
Height = 4095
Left = 6840
TabIndex = 23
Top = 0
Width = 4935
Begin VB.CommandButton Command9
Caption = "列出所有表"
Height = 375
Left = 3120
TabIndex = 33
Top = 1440
Width = 1695
End
Begin VB.ListBox List2
Height = 2400
Left = 120
TabIndex = 32
Top = 1440
Width = 2775
End
Begin VB.CommandButton Command7
Caption = "刪除字段"
Height = 255
Left = 1680
TabIndex = 29
Top = 840
Width = 1335
End
Begin VB.TextBox Text10
Height = 285
Left = 120
TabIndex = 28
Top = 480
Width = 2175
End
Begin VB.CommandButton Command6
Caption = "添加字段"
Height = 255
Left = 120
TabIndex = 26
Top = 840
Width = 1335
End
Begin VB.TextBox Text9
Height = 285
Left = 2880
TabIndex = 24
Top = 480
Width = 1935
End
Begin VB.Label Label8
Caption = "需要添加字段的表名稱"
Height = 255
Left = 120
TabIndex = 27
Top = 240
Width = 1935
End
Begin VB.Label Label7
Caption = "字段名稱"
Height = 255
Left = 2880
TabIndex = 25
Top = 240
Width = 1335
End
End
Begin VB.Frame Frame3
Caption = "添加刪除MDB里面的表"
Height = 1575
Left = 0
TabIndex = 15
Top = 4200
Width = 6735
Begin VB.CommandButton Command8
Caption = "刪除表"
Height = 375
Left = 120
TabIndex = 30
Top = 960
Width = 1455
End
Begin VB.TextBox Text8
Height = 285
Left = 3120
TabIndex = 22
Top = 840
Width = 2295
End
Begin VB.TextBox Text7
Height = 285
Left = 3120
TabIndex = 21
Top = 600
Width = 2295
End
Begin VB.TextBox Text6
Height = 285
Left = 3120
TabIndex = 19
Top = 360
Width = 2295
End
Begin VB.CommandButton Command5
Caption = "添加"
Height = 375
Left = 5520
TabIndex = 18
Top = 360
Width = 1095
End
Begin VB.TextBox Text5
Height = 285
Left = 120
TabIndex = 16
Top = 480
Width = 2055
End
Begin VB.Label Label9
Caption = "必須添加表名稱和字段名稱(三個字段填滿)"
Height = 255
Left = 2880
TabIndex = 31
Top = 1200
Width = 3615
End
Begin VB.Label Label6
Caption = "輸入字段"
Height = 255
Left = 3120
TabIndex = 20
Top = 120
Width = 2655
End
Begin VB.Label Label5
Caption = "輸入表名稱"
Height = 255
Left = 120
TabIndex = 17
Top = 240
Width = 1455
End
End
Begin VB.Frame Frame2
Caption = "列表/修改/刪除記錄"
Height = 2895
Left = 0
TabIndex = 6
Top = 1200
Width = 6735
Begin VB.TextBox Text4
Height = 285
Left = 3960
TabIndex = 12
Top = 1320
Width = 2415
End
Begin VB.TextBox Text3
Height = 285
Left = 3960
TabIndex = 11
Top = 960
Width = 2415
End
Begin VB.CommandButton Command4
Caption = "刪除"
Height = 375
Left = 3240
TabIndex = 10
Top = 2400
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "修改"
Height = 375
Left = 3240
TabIndex = 9
Top = 1680
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "列表"
Height = 375
Left = 3240
TabIndex = 8
Top = 240
Width = 1095
End
Begin VB.ListBox List1
Height = 2580
Left = 120
TabIndex = 7
Top = 240
Width = 3015
End
Begin VB.Label Label4
Caption = "E-Mail"
Height = 255
Left = 3240
TabIndex = 14
Top = 1320
Width = 735
End
Begin VB.Label Label3
Caption = "姓名"
Height = 255
Left = 3240
TabIndex = 13
Top = 960
Width = 975
End
End
Begin VB.Frame Frame1
Caption = "添加記錄"
Height = 1095
Left = 0
TabIndex = 0
Top = 0
Width = 6735
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 4200
TabIndex = 5
Top = 240
Width = 1095
End
Begin VB.TextBox Text2
Height = 285
Left = 720
TabIndex = 4
Top = 600
Width = 3375
End
Begin VB.TextBox Text1
Height = 285
Left = 720
TabIndex = 1
Top = 240
Width = 3375
End
Begin VB.Label Label2
Caption = "E-Mail"
Height = 255
Left = 120
TabIndex = 3
Top = 600
Width = 735
End
Begin VB.Label Label1
Caption = "姓名"
Height = 255
Left = 120
TabIndex = 2
Top = 240
Width = 975
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'這是個簡單的單機型數據庫入門代碼,可以從中學習數據庫操作的初級知識
'這里面的添加刪除表和添加刪除字段在添加記錄和刪除記錄這個版塊中沒有實際作用
'只是作為演示的一個用途,一般情況下先就設定好表和字段了,不需要實時開通表和記錄功能的
'在數據庫中進行SQL操作,看子程序list里面有打開數據庫時執行SQL的語句
Public Function Add() '公用的添加數據子程序
'程序在ACCESS2003 MDB下通過,并在ACCESS2000中建立了MDB數據庫文件
'聲明變量
Dim DB As Database '聲明DB變量用于數據庫
Dim RS As Recordset '聲明RS變量用于記錄集
Dim WS As Workspace '聲明WS變量用于工作空間
'這兒設置用于定義工作空間
Set WS = DBEngine.Workspaces(0)
'這兒設置數據庫連接語句,指向MDB文件
Set DB = WS.OpenDatabase(App.Path & "\dbtut.mdb")
'這開是打開數據庫MDB,并打開里面的表Email
Set RS = DB.OpenRecordset("email", dbOpenTable)
'添加一個空的新記錄
RS.AddNew
'把text1.text的內容寫入name
'把text2.text的內容寫入e-mail
RS("Name") = Text1.Text
RS("E-Mail") = Text2.Text
'更新update,也就是添加記錄進去
RS.Update
'關閉數據庫
DB.Close
End Function
Private Sub Command1_Click()
'引用公用程序ADD來完成添加動作
Add
'完成后清空輸入框中的內容
Text1.Text = ""
Text2.Text = ""
'引用公用程序list以完成更新所有記錄列表工作
List
End Sub
Private Sub Command2_Click()
'引用公用程序list以完成更新所有記錄列表工作,在這里起到從新查看記錄的作用
List
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -