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

📄 数据库_通用f5.frm

📁 <VB数理统计实用算法>书中的算法源程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmSQL 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   Caption         =   "查询"
   ClientHeight    =   4935
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6480
   LinkTopic       =   "Form1"
   ScaleHeight     =   4935
   ScaleWidth      =   6480
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox txtSQL 
      Appearance      =   0  'Flat
      Height          =   855
      Left            =   480
      MultiLine       =   -1  'True
      TabIndex        =   14
      Text            =   "数据库_通用F5.frx":0000
      Top             =   3960
      Width           =   5535
   End
   Begin VB.ListBox lstFDName2 
      Appearance      =   0  'Flat
      Height          =   2190
      Left            =   4800
      TabIndex        =   12
      Top             =   1200
      Width           =   1215
   End
   Begin VB.ListBox lstTDName2 
      Appearance      =   0  'Flat
      Height          =   2190
      Left            =   3360
      TabIndex        =   11
      Top             =   1200
      Width           =   1215
   End
   Begin VB.ListBox lstFDName1 
      Appearance      =   0  'Flat
      Height          =   2190
      Left            =   1920
      TabIndex        =   10
      Top             =   1200
      Width           =   1215
   End
   Begin VB.ListBox lstTDName1 
      Appearance      =   0  'Flat
      Height          =   2190
      Left            =   480
      TabIndex        =   9
      Top             =   1200
      Width           =   1215
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退    出"
      Height          =   375
      Left            =   4560
      TabIndex        =   4
      Top             =   240
      Width           =   1455
   End
   Begin VB.CommandButton cmdSQL 
      Caption         =   "查    询"
      Height          =   375
      Left            =   2880
      TabIndex        =   3
      Top             =   240
      Width           =   1455
   End
   Begin VB.Frame fraTDNumber 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "选择查询表的个数"
      ForeColor       =   &H80000008&
      Height          =   735
      Left            =   480
      TabIndex        =   0
      Top             =   120
      Width           =   1935
      Begin VB.OptionButton OptTwo 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "双表"
         ForeColor       =   &H80000008&
         Height          =   375
         Left            =   1080
         TabIndex        =   2
         Top             =   240
         Width           =   735
      End
      Begin VB.OptionButton OptOne 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "单表"
         ForeColor       =   &H80000008&
         Height          =   375
         Left            =   240
         TabIndex        =   1
         Top             =   240
         Value           =   -1  'True
         Width           =   735
      End
   End
   Begin VB.Label lblNotice2 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      ForeColor       =   &H80000008&
      Height          =   210
      Left            =   480
      TabIndex        =   15
      Top             =   3720
      Width           =   120
   End
   Begin VB.Label lblNotice1 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      ForeColor       =   &H80000008&
      Height          =   210
      Left            =   480
      TabIndex        =   13
      Top             =   3480
      Width           =   120
   End
   Begin VB.Label lblFDName2 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "字段表2"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   4800
      TabIndex        =   8
      Top             =   960
      Width           =   1215
   End
   Begin VB.Label lblTDName2 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "查询表2"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   3360
      TabIndex        =   7
      Top             =   960
      Width           =   1215
   End
   Begin VB.Label lblFDName1 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "字段表1"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   1920
      TabIndex        =   6
      Top             =   960
      Width           =   1215
   End
   Begin VB.Label lblTDName1 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "查询表1"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   480
      TabIndex        =   5
      Top             =   960
      Width           =   1215
   End
End
Attribute VB_Name = "frmSQL"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'窗体frmSQL
'SQL查询
Option Explicit
Dim strTDName1 As String, strTDName2 As String
Dim td1 As TableDef, td2 As TableDef

Private Sub Form_Load()
    lblTDName1.Visible = True               '指示查询表1的标签
    lstTDName1.Visible = True               '查询表1的列表框
    lblTDName2.Visible = False              '指示查询表2的标签
    lstTDName2.Visible = False              '查询表2的列表框
    lblFDName1.Visible = False              '指示字段表1的标签
    lstFDName1.Visible = False              '字段表1的列表框
    lblFDName2.Visible = False              '指示字段表2的标签
    lstFDName2.Visible = False              '字段表2的列表框
    lblNotice1.Visible = False
    lblNotice2.Visible = False
    cmdSQL.Visible = False                  '查询按钮
    txtSQL.Visible = False                  '保存SQL语句的文本框
'在列表框1显示数据表
    For Each td In db.TableDefs
        If (td.Attributes And dbSystemObject) = 0 Then  '甩掉系统表
            If (td.Attributes <> dbAttachedTable) Then  '甩掉附属表
                lstTDName1.AddItem td.Name              '用户表进入列表框
            End If
        End If
    Next
End Sub

'单击“单表”单选钮事件
Private Sub OptOne_Click()
    lblTDName1.Visible = True               '指示查询表1的标签
    lstTDName1.Visible = True               '查询表1的列表框
    lblTDName2.Visible = False              '指示查询表2的标签
    lstTDName2.Visible = False              '查询表2的列表框
    lblFDName1.Visible = False              '指示字段表1的标签
    lstFDName1.Visible = False              '字段表1的列表框
    lblFDName2.Visible = False              '指示字段表2的标签
    lstFDName2.Visible = False              '字段表2的列表框
End Sub

'单击“双表”单选钮事件
Private Sub OptTwo_Click()
    lblTDName2.Visible = True               '指示查询表2的标签
    lstTDName2.Visible = True               '查询表2的列表框
    lblFDName1.Visible = False              '指示字段表1的标签
    lstFDName1.Visible = False              '字段表1的列表框
    lblFDName2.Visible = False              '指示字段表2的标签
    lstFDName2.Visible = False              '字段表2的列表框
    lstTDName2.Clear
'在列表框2显示数据表
    For Each td In db.TableDefs
        If (td.Attributes And dbSystemObject) = 0 Then  '甩掉系统表
            If (td.Attributes <> dbAttachedTable) Then  '甩掉附属表
                lstTDName2.AddItem td.Name              '用户表进入列表框
            End If
        End If
    Next
End Sub

'单击列表框1事件
Private Sub lstTDName1_Click()
    lblFDName1.Visible = True               '指示字段表1的标签
    lstFDName1.Visible = True               '字段表1的列表框
    strTDName1 = lstTDName1                 '从选中的列表项取得原表名1
    lstFDName1.Clear                        '清除列表框
    Set td1 = db.TableDefs(strTDName1)      '打开原数据表1
    For Each fd In td1.Fields               '在列表框中列出原数据表1的字段名
        lstFDName1.AddItem fd.Name
    Next
    cmdSQL.Visible = True
    txtSQL.Visible = True
    lblNotice1.Visible = True
    lblNotice1.Caption = "参考上面所列出的字段在下面的文本框中键入SQL语句"
    lblNotice2.Visible = True
    lblNotice2.Caption = "在键入SQL语句时不能使用断句符换行,用箭头键即可"
End Sub

'单击列表框2事件
Private Sub lstTDName2_Click()
    lblFDName2.Visible = True               '指示字段表2的标签
    lstFDName2.Visible = True               '字段表2的列表框
    strTDName2 = lstTDName2                 '从选中的列表项取得原表名2
    lstFDName2.Clear                        '清除列表框
    Set td2 = db.TableDefs(strTDName2)      '打开原数据表2
    For Each fd In td2.Fields               '在列表框中列出原数据表2的字段名
        lstFDName2.AddItem fd.Name
    Next
End Sub

'执行SQL查询
Private Sub cmdSQL_Click()
'在键入SQL语句时不能加入断句符,用箭头键换行即可
    Dim strSQL As String
    strSQL = txtSQL.Text                    '从SQL文本框取得SQL语句
    db.Execute (strSQL)                     '执行SQL查询
    lblNotice1.Caption = "保存查询结果的新表已经建成," & _
                    "可以用“记录集”的“显示”浏览"
    lblNotice2.Visible = False
End Sub

'退出
Private Sub cmdExit_Click()
    Unload Me
    Load frmDatabase
    frmDatabase.Visible = True
End Sub

⌨️ 快捷键说明

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