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

📄 frmmain.frm

📁 个人VB学习源码精选,自己学习时的一些编程小程序,希望对大家有帮助
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form frmMain 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "DataBound Project"
   ClientHeight    =   4095
   ClientLeft      =   150
   ClientTop       =   720
   ClientWidth     =   7365
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4095
   ScaleWidth      =   7365
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  '窗口缺省
   Begin MSDBGrid.DBGrid DataGrid1 
      Bindings        =   "frmMain.frx":0000
      Height          =   2940
      Left            =   45
      OleObjectBlob   =   "frmMain.frx":0014
      TabIndex        =   2
      Top             =   90
      Width           =   7215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "E&xit"
      Height          =   285
      Left            =   4185
      TabIndex        =   1
      Top             =   3195
      Width           =   1230
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   3825
      Top             =   3150
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.ComboBox cboTables 
      Height          =   300
      Left            =   2160
      Style           =   2  'Dropdown List
      TabIndex        =   0
      Top             =   3195
      Width           =   1680
   End
   Begin VB.Data Data1 
      Caption         =   "Data1"
      Connect         =   "Access 2000;"
      DatabaseName    =   ""
      DefaultCursorType=   0  '缺省游标
      DefaultType     =   2  '使用 ODBC
      Exclusive       =   0   'False
      Height          =   375
      Left            =   45
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   ""
      Top             =   3195
      Width           =   1950
   End
   Begin VB.Menu mnuMain_File 
      Caption         =   "&File"
      Begin VB.Menu mnuFileOpen 
         Caption         =   "File &Open"
      End
      Begin VB.Menu mnuFileExit 
         Caption         =   "E&xit Program"
      End
   End
   Begin VB.Menu mnuMainDBCombo 
      Caption         =   "&Option"
      Begin VB.Menu mnuDBComboSites 
         Caption         =   "Change Contact &Sites"
      End
      Begin VB.Menu mnuProferences 
         Caption         =   "&Preferences"
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private btState As Byte
Private dbClients As Database
Private bNewDB As Boolean

Private Sub cboTables_Click()
    If bNewDB Then Exit Sub
    Data1.RecordSource = "Select * from " & cboTables.List(cboTables.ListIndex)
    Data1.Refresh
    DataGrid1.ReBind
    If cboTables.ListIndex <> 0 Then
        mnuMainDBCombo.Enabled = False
    Else
        mnuMainDBCombo.Enabled = True
    End If
End Sub

Private Sub Command1_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Data1.Caption = "<NOT SET>"
End Sub
Public Property Get MainDataCtl() As Control
    Set MainDataCtl = Data1
End Property
Public Property Get MainGrid() As Control
    Set MainGrid = DataGrid1
End Property
Public Property Get DataBaseName() As String
    DataBaseName = CommonDialog1.FileName
End Property
Public Property Get ClientID() As Long
    ClientID = Data1.Recordset![ClientID]
End Property

Private Sub Form_Unload(Cancel As Integer)
    If btState And cValidDatabase Then
        dbClients.Close
    End If
    Set dbClients = Nothing
    Set frmMain = Nothing
End Sub

Private Sub mnuDBComboSites_Click()
    Screen.MousePointer = vbHourglass
    frmDBCombo.Show vbModal
End Sub

Private Sub mnuFileExit_Click()
    Unload Me
End Sub

Private Sub mnuFileOpen_Click()
    Me.MousePointer = vbHourglass
    On Error Resume Next
    CommonDialog1.FileName = "*.MDB"
    CommonDialog1.ShowOpen
    DoEvents
    bNewDB = True
    If Err Then
        If Not btState And cValidDatabase Then
            btState = btState And cInvalidDatabase
        End If
    Else
        If GetDatabase(dbClients, CStr(CommonDialog1.FileName)) Then
            Data1.DataBaseName = CommonDialog1.FileName
            LoadFieldCombo
            btState = btState Or cValidDatabase
        Else
            If Not btState And cValidDatabase Then
                btState = btState And cInvalidDatabase
            End If
        End If
    End If
    bNewDB = False
    If btState And cValidDatabase Then '
        mnuMainDBCombo.Enabled = True
        cboTables.ListIndex = 0
        Data1.Caption = "Clients.mdb"
    Else
        mnuMainDBCombo.Enabled = False
        cboTables.Clear
        Data1.Caption = "<NOT SET>"
    End If
    Me.MousePointer = vbDefault
End Sub
Public Sub LoadFieldCombo()
    Dim tdfTables As TableDef
    cboTables.Clear
    For Each tdfTables In dbClients.TableDefs
        If InStr(tdfTables.Name, "MSys") < 1 Then
            cboTables.AddItem tdfTables.Name
            'Debug.Print tdfTables.Name
        End If
    Next tdfTables
End Sub

Private Sub mnuProferences_Click()
    Screen.MousePointer = vbHourglass
    frmSetPreferences.Show vbModal
End Sub

⌨️ 快捷键说明

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