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

📄 form1.frm

📁 vb数据库编程资料
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2055
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6180
   LinkTopic       =   "Form1"
   ScaleHeight     =   2055
   ScaleWidth      =   6180
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   5400
      TabIndex        =   8
      Top             =   0
      Width           =   735
   End
   Begin VB.CommandButton Command2 
      Caption         =   "删除索引"
      Height          =   495
      Left            =   2280
      TabIndex        =   6
      Top             =   1200
      Width           =   1815
   End
   Begin VB.ListBox List2 
      Height          =   1320
      Left            =   4560
      TabIndex        =   5
      Top             =   480
      Width           =   1455
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   3120
      TabIndex        =   4
      Top             =   0
      Width           =   735
   End
   Begin VB.CommandButton Command1 
      Caption         =   "删除表"
      Height          =   375
      Left            =   2280
      TabIndex        =   1
      Top             =   600
      Width           =   1815
   End
   Begin VB.ListBox List1 
      Height          =   1320
      Left            =   360
      TabIndex        =   0
      Top             =   480
      Width           =   1455
   End
   Begin VB.Label Label3 
      Caption         =   "索引数:"
      Height          =   375
      Left            =   4560
      TabIndex        =   7
      Top             =   0
      Width           =   735
   End
   Begin VB.Label Label2 
      Caption         =   "表数:"
      Height          =   255
      Left            =   2280
      TabIndex        =   3
      Top             =   120
      Width           =   615
   End
   Begin VB.Label Label1 
      Caption         =   "教学数据库中的表"
      Height          =   255
      Left            =   360
      TabIndex        =   2
      Top             =   120
      Width           =   1695
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CurDir As String
Dim jxdb As Database
Dim biao As TableDef
Dim Myindex As Index
Private Sub Command1_Click()
  jxdb.TableDefs.Delete List1.Text  '删除选定的表
  Call DispTableName   '调用DispTableName重新显示表名和表的数目
End Sub
Private Sub Command2_Click()
  jxdb.TableDefs(List1.Text).Indexes.Delete List2.Text '删除选定表的选定索引
  Call DispIndexName '重新显示所有索引名和索引数量
End Sub

Private Sub Form_Load()
  Set jxdb = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\教学") '打开数据库
  Call DispTableName '调用DispTableName显示表名和表的数目
End Sub
Private Sub DispTableName()
  List1.Clear  '清除掉列表框中的列表项
  With jxdb
     For Each biao In .TableDefs
        List1.AddItem biao.Name  '把表名添加到列表框中
     Next biao
     Text1.Text = .TableDefs.Count  '把表的数量显示在文本框中
  End With
End Sub

Private Sub DispIndexName()
  List2.Clear  '清除掉列表框中的列表项
  Set biao = jxdb.TableDefs(List1.Text)
  With biao
     For Each Myindex In .Indexes
        List2.AddItem Myindex.Name  '把索引名添加到列表框中
     Next Myindex
     Text2.Text = .Indexes.Count   '把索引的数量显示在文本框中
  End With
End Sub

Private Sub List1_Click()
  Call DispIndexName
End Sub

⌨️ 快捷键说明

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