frmstart.frm
来自「16 relay output channels and 16 isolated」· FRM 代码 · 共 570 行 · 第 1/2 页
FRM
570 行
VERSION 5.00
Begin VB.Form frmDevSel
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 3 'Fixed Dialog
Caption = "Multiple Analog Input with Software Trigger Demo"
ClientHeight = 4785
ClientLeft = 3630
ClientTop = 2145
ClientWidth = 4605
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"
LockControls = -1 'True
PaletteMode = 1 'UseZOrder
ScaleHeight = 4785
ScaleWidth = 4605
Begin VB.ComboBox CmbNumChan
Height = 315
Left = 3120
Style = 2 'Dropdown List
TabIndex = 14
ToolTipText = "Logical Channel Number"
Top = 1200
Width = 1215
End
Begin VB.ComboBox CmbStartChan
Height = 315
ItemData = "FRMSTART.frx":0000
Left = 3120
List = "FRMSTART.frx":0007
Style = 2 'Dropdown List
TabIndex = 13
Top = 480
Width = 1215
End
Begin VB.CommandButton cmdGain
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "&Gain List"
Enabled = 0 'False
Height = 495
Left = 3120
TabIndex = 12
Top = 3720
Width = 1215
End
Begin VB.Frame Frame1
BackColor = &H80000005&
Caption = "Gain option"
Height = 1935
Left = 240
TabIndex = 8
Top = 2640
Width = 2535
Begin VB.ListBox lstVoltageRange
Appearance = 0 'Flat
Height = 810
Left = 120
TabIndex = 10
Top = 960
Width = 2175
End
Begin VB.CheckBox ChkGainCde
BackColor = &H80000005&
Caption = "Use overall gain code"
Height = 255
Left = 120
TabIndex = 9
Top = 360
Value = 1 'Checked
Width = 2295
End
Begin VB.Label labVoltageRange
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Voltage Range"
ForeColor = &H80000008&
Height = 255
Left = 120
TabIndex = 11
Top = 720
Width = 1335
End
End
Begin VB.ListBox lstModule
Appearance = 0 'Flat
Height = 810
Left = 240
TabIndex = 4
Top = 1680
Width = 2535
End
Begin VB.CommandButton cmdExit
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "E&xit"
Height = 495
Left = 3120
TabIndex = 2
Top = 2400
Width = 1215
End
Begin VB.CommandButton cmdRun
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "&Run..."
Height = 495
Left = 3120
TabIndex = 1
Top = 1800
Width = 1215
End
Begin VB.ListBox lstDevice
Appearance = 0 'Flat
Height = 810
Left = 240
TabIndex = 0
Top = 480
Width = 2535
End
Begin VB.Label labStopChan
BackColor = &H00C0C0C0&
Caption = "Num of Chan"
Height = 255
Left = 3120
TabIndex = 7
Top = 960
Width = 1215
End
Begin VB.Label labStartChan
BackColor = &H00C0C0C0&
Caption = "Start Channel"
Height = 255
Left = 3120
TabIndex = 6
Top = 240
Width = 1215
End
Begin VB.Label labModule
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Select a module"
ForeColor = &H80000008&
Height = 255
Left = 480
TabIndex = 5
Top = 1440
Width = 1575
End
Begin VB.Label labDevLst
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Select a device from list"
ForeColor = &H80000008&
Height = 255
Left = 480
TabIndex = 3
Top = 240
Width = 2175
End
End
Attribute VB_Name = "frmDevSel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Response As Integer
Dim gnNumOfSubdevices As Integer
Dim bRun As Boolean
Function TestStr(DStr As String, TStr As String) As Boolean
Dim lenD, lenT As Integer
Dim i As Integer
TestStr = False
lenD = Len(DStr)
lenT = Len(TStr)
For i = 1 To (lenD - lenT + 1)
If (Mid(DStr, i, lenT) = TStr) Then
TestStr = True
End If
Next i
If DStr = "" Then
TestStr = True
End If
End Function
Private Sub ChkGainCde_Click()
Dim i As Integer
For i = 0 To lpDevFeatures.usMaxAISiglChl - 1
usGainIndex(i) = lstVoltageRange.ListIndex
Next i
If (ChkGainCde) Then
cmdGain.Enabled = False
lstVoltageRange.Enabled = True
Else
cmdGain.Enabled = True
lstVoltageRange.Enabled = False
End If
End Sub
Private Sub CmbStartChan_Click()
Dim i, num As Integer
Dim iMaxSingleChannel As Integer
Dim iMaxDiffChannel As Integer
CmbNumChan.Clear
'get the max channel number
iMaxSingleChannel = lpDevFeatures.usMaxAISiglChl
iMaxDiffChannel = lpDevFeatures.usMaxAIDiffChl
If (lpDEVCONFIG_AI.ulChanConfig = 1) Then
num = iMaxDiffChannel
ElseIf iMaxSingleChannel > iMaxDiffChannel Then
num = iMaxSingleChannel
Else
num = iMaxDiffChannel
End If
num = num - Val(CmbStartChan.Text)
For i = 1 To num
CmbNumChan.AddItem (Str(i))
Next i
' CmbNumChan.Text = CmbNumChan.List(0)
CmbNumChan.ListIndex = 0
End Sub
Private Sub cmdExit_Click()
If bRun Then
ErrCde = DRV_DeviceClose(DeviceHandle)
If (ErrCde <> 0) Then
DRV_GetErrorMessage ErrCde, szErrMsg
Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
End If
End If
End
End Sub
Private Sub cmdGain_Click()
frmGainCdeSet.Show
End Sub
Private Sub cmdRun_Click()
' The Original default is the value of lpDevConfig_AI.usGainCtrMode.
' Because this program uses external Trigger Signal, so AiCtrMode is
' set to 1. (1 External trigger) Since we find something wrong, so we
' set it to 0 for temporary.
AiCtrMode = 0
usStartChan = Val(CmbStartChan.Text)
usNumChan = Val(CmbNumChan.Text)
ptMAIConfig.StartChan = usStartChan
ptMAIConfig.NumChan = usNumChan
' Here you must point the GainArray to the Start Channel, not the AI Channel
If gnNumOfSubdevices = 0 Then
ptMAIConfig.GainArray = DRV_GetAddress(usGainCode(usStartChan))
Else
ptMAIConfig.GainArray = Null
End If
ErrCde = DRV_MAIConfig(DeviceHandle, ptMAIConfig)
If (ErrCde <> 0) Then
DRV_GetErrorMessage ErrCde, szErrMsg
Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
Exit Sub
End If
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?