frmrun.frm

来自「16 relay output channels and 16 isolated」· FRM 代码 · 共 201 行

FRM
201
字号
VERSION 5.00
Begin VB.Form frmRun 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Alarm Demo"
   ClientHeight    =   2880
   ClientLeft      =   3156
   ClientTop       =   2268
   ClientWidth     =   4452
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   7.8
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H80000008&
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2880
   ScaleWidth      =   4452
   Begin VB.Frame frmSampleRate 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Sampling Rate"
      ForeColor       =   &H80000008&
      Height          =   1095
      Left            =   240
      TabIndex        =   4
      Top             =   1080
      Width           =   3975
      Begin VB.HScrollBar hscrlFreq 
         Height          =   375
         LargeChange     =   10
         Left            =   120
         Max             =   100
         TabIndex        =   5
         Top             =   360
         Value           =   10
         Width           =   3615
      End
      Begin VB.Label labFreqHigh 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "10 (time/s)"
         ForeColor       =   &H80000008&
         Height          =   255
         Left            =   2880
         TabIndex        =   1
         Top             =   720
         Width           =   975
      End
      Begin VB.Label labFrequencyLow 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "0 (Stop)"
         ForeColor       =   &H80000008&
         Height          =   255
         Left            =   120
         TabIndex        =   2
         Top             =   720
         Width           =   855
      End
   End
   Begin VB.Timer tmrRead 
      Left            =   3960
      Top             =   720
   End
   Begin VB.CommandButton cmdExit 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "E&xit"
      Height          =   495
      Left            =   1440
      TabIndex        =   0
      Top             =   2280
      Width           =   1455
   End
   Begin VB.Shape shapLow 
      BorderColor     =   &H000000FF&
      BorderStyle     =   0  'Transparent
      FillColor       =   &H00808080&
      FillStyle       =   0  'Solid
      Height          =   735
      Left            =   3120
      Shape           =   3  'Circle
      Top             =   240
      Width           =   735
   End
   Begin VB.Label labLowAlarm 
      BackColor       =   &H80000005&
      Caption         =   "Low Alarm"
      Height          =   255
      Left            =   2280
      TabIndex        =   6
      Top             =   120
      Width           =   1095
   End
   Begin VB.Shape shapHigh 
      BorderColor     =   &H000000FF&
      BorderStyle     =   0  'Transparent
      FillColor       =   &H00808080&
      FillStyle       =   0  'Solid
      Height          =   735
      Left            =   1200
      Shape           =   3  'Circle
      Top             =   240
      Width           =   735
   End
   Begin VB.Label labHighAlarm 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "High Alarm"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   360
      TabIndex        =   3
      Top             =   120
      Width           =   1095
   End
End
Attribute VB_Name = "frmRun"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub cmdExit_Click()
    ErrCde = DRV_AlarmReset(DeviceHandle, AlarmChan)
    If (ErrCde <> 0) Then
        DRV_GetErrorMessage ErrCde, szErrMsg
        Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
        Exit Sub
    End If
    
    frmRun.Hide
    frmDevSel.Show
    frmDevSel.cmdExit.SetFocus
End Sub




Private Sub Form_Load()
  hscrlFreq_Change
End Sub

Private Sub Form_Unload(Cancel As Integer)
    frmDevSel.Show
End Sub

Private Sub hscrlFreq_Change()
    If hscrlFreq.value = 0 Then
        tmrRead.Interval = 0
    Else
        tmrRead.Interval = 10000 / hscrlFreq.value
    End If
    tmrRead.Enabled = True
End Sub


Private Sub tmrRead_Timer()
  Dim LoState As Integer
  Dim HiState As Integer
   
  shapHigh.FillColor = QBColor(8)
  shapLow.FillColor = QBColor(8)
  
  ptAlarmCheck.chan = AlarmChan
  ptAlarmCheck.HiState = DRV_GetAddress(HiState)
  ptAlarmCheck.LoState = DRV_GetAddress(LoState)
  
  ErrCde = DRV_AlarmCheck(DeviceHandle, ptAlarmCheck)
  If (ErrCde <> 0) Then
    DRV_GetErrorMessage ErrCde, szErrMsg
    Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
    Exit Sub
  End If
  
  If HiState <> 0 Then
    shapHigh.FillColor = QBColor(12)
  Else
    shapHigh.FillColor = QBColor(8)
  End If
  
  If LowState <> 0 Then
    shapLow.FillColor = QBColor(12)
  Else
    shapLow.FillColor = QBColor(8)
  End If
End Sub





⌨️ 快捷键说明

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