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

📄 frmrun.frm

📁 16 relay output channels and 16 isolated digital input channels LED indicators to show activated
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmRun 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Frequency Demo"
   ClientHeight    =   2925
   ClientLeft      =   3540
   ClientTop       =   1725
   ClientWidth     =   3690
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   8.25
      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     =   2925
   ScaleWidth      =   3690
   Begin VB.Frame frmCount 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Counting Value"
      ForeColor       =   &H80000008&
      Height          =   855
      Left            =   240
      TabIndex        =   6
      Top             =   120
      Width           =   3135
      Begin VB.Label labCount 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "0"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   26.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   495
         Left            =   120
         TabIndex        =   7
         Top             =   240
         Width           =   2895
      End
   End
   Begin VB.Frame frmSampleRate 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Sampling Rate"
      ForeColor       =   &H80000008&
      Height          =   1095
      Left            =   240
      TabIndex        =   5
      Top             =   1080
      Width           =   3255
      Begin VB.HScrollBar hscrlFreq 
         Height          =   375
         LargeChange     =   10
         Left            =   120
         Max             =   100
         TabIndex        =   3
         Top             =   360
         Value           =   10
         Width           =   3015
      End
      Begin VB.Label labFreqHigh 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "10 (time/s)"
         ForeColor       =   &H80000008&
         Height          =   255
         Left            =   2160
         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 
      Enabled         =   0   'False
      Left            =   1680
      Top             =   2160
   End
   Begin VB.CommandButton cmdRead 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "&Read one data"
      Height          =   495
      Left            =   2040
      TabIndex        =   4
      Top             =   2280
      Width           =   1455
   End
   Begin VB.CommandButton cmdExit 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "E&xit"
      Height          =   495
      Left            =   240
      TabIndex        =   0
      Top             =   2280
      Width           =   1455
   End
End
Attribute VB_Name = "frmRun"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim lCount As Long

Private Sub cmdExit_Click()
    Unload frmRun
End Sub

Private Sub cmdRead_Click()
  Dim gfFreq As Single
  
  tmrRead.Enabled = False
  lpCounterFreqStart.counter = frmDevSel.lstChannel.ListIndex
  lpCounterFreqStart.GatePeriod = Val(frmDevSel.txtGP.Text)
  lpCounterFreqStart.GateMode = 0 ' No use here
  
  ErrCde = DRV_CounterFreqStart(DeviceHandle, lpCounterFreqStart)
  If (ErrCde <> 0) Then
        DRV_GetErrorMessage ErrCde, szErrMsg
        Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
        Exit Sub
  End If

  lpCounterFreqRead.counter = lpCounterFreqStart.counter
  lpCounterFreqRead.freq = DRV_GetAddress(gfFreq)
  ErrCde = DRV_CounterFreqRead(DeviceHandle, lpCounterFreqRead)
  If (ErrCde <> 0) Then
        DRV_GetErrorMessage ErrCde, szErrMsg
        Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
        Exit Sub
  End If
  labCount.Caption = Str(gfFreq)
End Sub

Private Sub Form_Load()
    hscrlFreq_Change
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Dim Response As Long
    Dim dwExitCode As Long
    
    ErrCde = DRV_CounterReset(DeviceHandle, lpCounterFreqRead.counter)
    
    If (ErrCde <> 0) Then
        DRV_GetErrorMessage ErrCde, szErrMsg
        Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
        Exit Sub
    End If
    
   
    tmrRead.Enabled = False
    frmDevSel.Show
    frmDevSel.cmdExit.SetFocus
    
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 gfFreq As Single
  
  lpCounterFreqRead.counter = lpCounterFreqStart.counter
  lpCounterFreqRead.freq = DRV_GetAddress(gfFreq)
  ErrCde = DRV_CounterFreqRead(DeviceHandle, lpCounterFreqRead)
  If (ErrCde <> 0) Then
        DRV_GetErrorMessage ErrCde, szErrMsg
        Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
        Exit Sub
  End If
  labCount.Caption = Format(gfFreq, 0#)
  
End Sub

⌨️ 快捷键说明

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