⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 数据库
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.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 MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Bindings        =   "Form1.frx":0000
      Height          =   2775
      Left            =   2640
      TabIndex        =   1
      Top             =   120
      Width           =   3735
      _ExtentX        =   6588
      _ExtentY        =   4895
      _Version        =   393216
   End
   Begin VB.Data Data1 
      Caption         =   "Data1"
      Connect         =   "Access"
      DatabaseName    =   "D:\vb\edittbls\Data.mdb"
      DefaultCursorType=   0  '缺省游标
      DefaultType     =   2  '使用 ODBC
      Exclusive       =   0   'False
      Height          =   345
      Left            =   2640
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   ""
      Top             =   3000
      Visible         =   0   'False
      Width           =   3615
   End
   Begin VB.ListBox List1 
      DataSource      =   "Data1"
      Height          =   3120
      Left            =   0
      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.Visible = True
    
   ' MSFlexGrid1.DataSource = Data1
    'MSFlexGrid1.DataField = List1.List(List1.ListIndex)
    Data1.Refresh
    
    ' Make the Data and DBGrid controls visible.
    
    MSFlexGrid1.Visible = True
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -