frmrun.frm

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

FRM
247
字号
VERSION 5.00
Begin VB.Form frmRun 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Analog Input Demo"
   ClientHeight    =   2640
   ClientLeft      =   2115
   ClientTop       =   1500
   ClientWidth     =   3990
   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     =   2640
   ScaleWidth      =   3990
   Begin VB.Timer tmrLed 
      Interval        =   400
      Left            =   1560
      Top             =   0
   End
   Begin VB.Frame frmSampleRate 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Sampling Rate"
      ForeColor       =   &H80000008&
      Height          =   855
      Left            =   240
      TabIndex        =   6
      Top             =   1560
      Width           =   3495
      Begin VB.TextBox txtSample 
         Height          =   285
         Left            =   1440
         Locked          =   -1  'True
         TabIndex        =   8
         Text            =   "txtSample"
         Top             =   600
         Width           =   495
      End
      Begin VB.HScrollBar hscrlFreq 
         Height          =   255
         LargeChange     =   10
         Left            =   120
         Max             =   100
         TabIndex        =   7
         Top             =   240
         Value           =   10
         Width           =   3255
      End
      Begin VB.Label labFreqHigh 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "10 (time/s)"
         ForeColor       =   &H80000008&
         Height          =   255
         Left            =   2400
         TabIndex        =   1
         Top             =   480
         Width           =   975
      End
      Begin VB.Label labFrequencyLow 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "0 (Stop)"
         ForeColor       =   &H80000008&
         Height          =   255
         Left            =   120
         TabIndex        =   2
         Top             =   480
         Width           =   855
      End
   End
   Begin VB.Timer tmrRead 
      Left            =   0
      Top             =   1200
   End
   Begin VB.CommandButton cmdRead 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "&Read one data"
      Height          =   495
      Left            =   2280
      TabIndex        =   5
      Top             =   120
      Width           =   1455
   End
   Begin VB.TextBox txtVoltRead 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   39.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1035
      Left            =   240
      Locked          =   -1  'True
      TabIndex        =   3
      Text            =   "0.00"
      Top             =   360
      Width           =   1935
   End
   Begin VB.CommandButton cmdExit 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "E&xit"
      Height          =   495
      Left            =   2280
      TabIndex        =   0
      Top             =   840
      Width           =   1455
   End
   Begin VB.Shape shapLed 
      BorderColor     =   &H000000FF&
      BorderStyle     =   0  'Transparent
      FillColor       =   &H00808080&
      FillStyle       =   0  'Solid
      Height          =   255
      Left            =   240
      Shape           =   3  'Circle
      Top             =   120
      Width           =   255
   End
   Begin VB.Label labVolt 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Voltage read"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   600
      TabIndex        =   4
      Top             =   120
      Width           =   1215
   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()
    frmRun.Hide
    frmDevSel.Show
    frmDevSel.cmdExit.SetFocus
End Sub

Private Sub cmdRead_Click()
    Dim tt As Long
    Dim voltage As Single
    
    tmrRead.Enabled = False
    
    AiVolIn.chan = lpAIConfig.DasChan
    AiVolIn.gain = lpAIConfig.DasGain
    'AiVolIn.TrigMode = AiCtrMode
    'internal triger
    AiVolIn.TrigMode = 0
    AiVolIn.voltage = DRV_GetAddress(voltage)
    shapLed.FillColor = QBColor(12)
    
    ErrCde = DRV_AIVoltageIn(DeviceHandle, AiVolIn)
    If (ErrCde <> 0) Then
      DRV_GetErrorMessage ErrCde, szErrMsg
      Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
      Exit Sub
    End If
    UpDateValue (voltage)
End Sub

Private Sub cmdRead_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    shapLed.FillColor = QBColor(12)
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
    
    txtSample.Text = Format((hscrlFreq.value / 10), "###0.00")
    ' "Read One Shot" would disable the "trmREAD" Timer,
    ' so it need to enable here.
    tmrRead.Enabled = True
    tmrLed.Enabled = True
End Sub

Private Sub tmrLed_Timer()
    shapLed.FillColor = QBColor(8)
End Sub

Private Sub tmrRead_Timer()
  Dim voltage As Single
   
  shapLed.FillColor = QBColor(12)
  AiVolIn.chan = lpAIConfig.DasChan
  AiVolIn.gain = lpAIConfig.DasGain
  'AiVolIn.TrigMode = AiCtrMode
  'internal triger
  AiVolIn.TrigMode = 0
  AiVolIn.voltage = DRV_GetAddress(voltage)
  ErrCde = DRV_AIVoltageIn(DeviceHandle, AiVolIn)
  If (ErrCde <> 0) Then
    DRV_GetErrorMessage ErrCde, szErrMsg
    Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
    Exit Sub
  End If
  UpDateValue (voltage)
End Sub

Private Sub UpDateValue(fValue As Single)
    ' Since the output box is too small to display all the digits
    ' of the input voltage, so it must use to format to get better
    ' display.
    txtVoltRead.Text = Format(fValue, "###0.00")
End Sub

Private Sub txtVoltRead_Click()
  tmrRead.Enabled = True
  tmrLed.Enabled = True
End Sub


⌨️ 快捷键说明

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