📄 form1.frm
字号:
VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3450
ClientLeft = 1665
ClientTop = 1515
ClientWidth = 6480
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 3450
ScaleWidth = 6480
Begin MSDBGrid.DBGrid DBGrid1
Bindings = "Form1.frx":0000
Height = 2775
Left = 2760
OleObjectBlob = "Form1.frx":0010
TabIndex = 1
Top = 120
Visible = 0 'False
Width = 3615
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 300
Left = 2760
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 3000
Visible = 0 'False
Width = 3615
End
Begin VB.ListBox List1
Height = 2595
Left = 120
TabIndex = 0
Top = 120
Width = 2535
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
Dim dbname As String
Dim db As Database
Dim qdef As QueryDef
Dim td As TableDef
' Open the database.
dbname = App.Path
If Right$(dbname, 1) <> "\" Then dbname = dbname & "\"
dbname = dbname & "data.mdb"
Set db = OpenDatabase(dbname)
' List the table names.
For Each td In db.TableDefs
' Do not allow the system tables.
If Left$(td.Name, 4) <> "MSys" Then _
List1.AddItem td.Name
Next td
db.Close
' Attach the Data control to the database.
Data1.DatabaseName = dbname
End Sub
' Open the selected table.
Private Sub List1_Click()
Dim table_name As String
Dim sql As String
table_name = List1.List(List1.ListIndex)
sql = "SELECT * FROM " & table_name
Data1.Caption = table_name
Data1.RecordSource = sql
Data1.Refresh
' Make the Data and DBGrid controls visible.
Data1.Visible = True
DBGrid1.Visible = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -