📄 mdb3.frm
字号:
VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form Form1
Caption = "mdb3"
ClientHeight = 6090
ClientLeft = 60
ClientTop = 345
ClientWidth = 13215
LinkTopic = "Form1"
ScaleHeight = 6090
ScaleWidth = 13215
StartUpPosition = 3 '窗口缺省
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access 2000;"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
EOFAction = 2 'Add New
Exclusive = 0 'False
Height = 405
Left = 4080
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 240
Width = 4095
End
Begin MSDBGrid.DBGrid DBGrid1
Bindings = "mdb3.frx":0000
Height = 5295
Left = 4080
OleObjectBlob = "mdb3.frx":0014
TabIndex = 6
Top = 720
Width = 5175
End
Begin VB.TextBox Text1
Height = 5295
Left = 9360
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 5
Top = 720
Width = 3855
End
Begin VB.CommandButton Command1
Caption = "Execute"
Height = 375
Left = 3120
TabIndex = 4
Top = 240
Width = 855
End
Begin VB.TextBox Text2
Height = 390
Left = 0
TabIndex = 3
Text = "select * from"
Top = 240
Width = 3015
End
Begin VB.FileListBox File1
Height = 4050
Left = 0
TabIndex = 2
Top = 700
Width = 4015
End
Begin VB.ListBox List1
Height = 5280
Left = 0
TabIndex = 0
Top = 700
Width = 4015
End
Begin VB.Label Label1
Caption = "Dblclick here for another *.mdb "
Height = 255
Left = 0
TabIndex = 1
Top = 0
Width = 2895
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 Command1_Click()
Data1.RecordSource = Text2 '例如select * from 基础知识 where 类别 like '%数据库编程%'
Data1.Refresh
End Sub
Private Sub DBGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
Text1 = DBGrid1.Text
End Sub
Private Sub File1_Click()
On Error Resume Next
Dim dbname As String
Dim db As Database
Dim qdef As QueryDef
Dim td As TableDef
File1.Visible = False
List1.Clear
' open the database.
dbname = App.Path
If Right$(dbname, 1) <> "\" Then dbname = dbname & "\"
dbname = dbname & File1.FileName
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
Private Sub form_load()
File1.Path = App.Path
File1.Pattern = "*.mdb"
End Sub
Private Sub Form_Resize()
On Error Resume Next
List1.Height = Form1.ScaleHeight * 0.9
DBGrid1.Height = Form1.ScaleHeight * 0.9
Text1.Height = Form1.ScaleHeight * 0.9
Text1.Width = (Form1.ScaleWidth - List1.Width - DBGrid1.Width) * 0.9
End Sub
Private Sub Label1_DblClick()
File1.Visible = True
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
End Sub
Private Sub Text1_Click()
DBGrid1.Text = Text1
End Sub
Private Sub Text1_DblClick()
Dim i%
i = MsgBox("确实要删除该记录吗?", vbYesNo)
If i = vbYes Then
Data1.Recordset.Delete
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -