frmbackuptest.frm

来自「《VB6数据库开发指南》所有的例程的源码」· FRM 代码 · 共 100 行

FRM
100
字号
VERSION 5.00
Object = "{1B51D052-02A7-11D1-9AF0-004033373A8F}#4.0#0"; "EnhancedTimer.ocx"
Begin VB.Form frmBackupTest 
   Caption         =   "Backup Test Form"
   ClientHeight    =   1350
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   1350
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin prjEnhancedTimer.ctlEnhancedTimer ctlEnhancedTimer1 
      Left            =   480
      Top             =   720
      _ExtentX        =   741
      _ExtentY        =   741
   End
   Begin VB.CommandButton cmdStartTimer 
      Caption         =   "&Start Timer"
      Height          =   375
      Left            =   1200
      TabIndex        =   2
      Top             =   720
      Width           =   3135
   End
   Begin VB.TextBox txtTriggerTime 
      Height          =   375
      Left            =   1200
      TabIndex        =   0
      Top             =   240
      Width           =   3135
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "Trigger Time:"
      Height          =   195
      Left            =   120
      TabIndex        =   1
      Top             =   240
      Width           =   930
   End
End
Attribute VB_Name = "frmBackupTest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private usrBackupTable As New clsBackupTable
Private dbOpenDb As Database

Private Sub cmdStartTimer_Click()
' Start the timer
    
    If Not IsDate(txtTriggerTime.Text) Then
        MsgBox "Invalid time format"
    Else
        ctlEnhancedTimer1.TimeToTrigger = txtTriggerTime.Text
        ctlEnhancedTimer1.Enabled = True
    End If
    
End Sub

Private Sub ctlEnhancedTimer1_ExtendedTimerPop()
    
    On Error GoTo BackupError
    
    Debug.Print "Extended timer pop"
    usrBackupTable.DoBackup
    ' Restart the timer
    ctlEnhancedTimer1.Enabled = True
    Exit Sub

BackupError:
    MsgBox Err.Description & " from " & Err.Source _
        & " Number = " & CStr(Err.Number)
    Exit Sub
    
End Sub

Private Sub Form_Load()
Dim strDbName As String

    On Error GoTo DbError
    strDbName = App.Path & "\Expense.mdb"
    ' Open a database for the Backup class to use
    Set dbOpenDb = Workspaces(0).OpenDatabase(strDbName)
    Set usrBackupTable.DatabaseObject = dbOpenDb
    usrBackupTable.TableName = "Expenses"
    Exit Sub
    
DbError:
    MsgBox Err.Description & " from " & Err.Source _
        & " Number = " & CStr(Err.Number)
    End
    
End Sub

⌨️ 快捷键说明

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