📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BackColor = &H00808000&
Caption = "Analog-Input Demo, Using Channel Scan"
ClientHeight = 3912
ClientLeft = 480
ClientTop = 1584
ClientWidth = 8796
LinkTopic = "Form1"
ScaleHeight = 3912
ScaleWidth = 8796
Begin VB.Frame Frame4
BackColor = &H00FF8080&
Caption = " Board Setting "
Height = 612
Left = 2760
TabIndex = 5
Top = 3120
Width = 2292
Begin VB.TextBox eTotal
Alignment = 1 'Right Justify
BackColor = &H0000FFFF&
Enabled = 0 'False
Height = 288
Left = 600
TabIndex = 7
Text = "0"
Top = 240
Width = 372
End
Begin VB.TextBox eSelect
Alignment = 1 'Right Justify
BackColor = &H0000FF00&
Height = 288
Left = 1800
TabIndex = 6
Text = "0"
Top = 240
Width = 372
End
Begin VB.Label Label1
BackColor = &H00FF8080&
Caption = "Total"
ForeColor = &H00FFFFFF&
Height = 252
Left = 120
TabIndex = 9
Top = 240
Width = 492
End
Begin VB.Label Label7
BackColor = &H00FF8080&
Caption = "Active"
ForeColor = &H00FFFFFF&
Height = 252
Left = 1320
TabIndex = 8
Top = 240
Width = 492
End
End
Begin VB.Frame Frame1
BackColor = &H0080C0FF&
Caption = " Analog Input Setting "
Height = 612
Left = 120
TabIndex = 4
Top = 3120
Width = 2532
Begin VB.ComboBox cbCardType
BackColor = &H0000FF00&
Height = 288
ItemData = "Form1.frx":0000
Left = 1080
List = "Form1.frx":000A
Style = 2 'Dropdown List
TabIndex = 10
Top = 240
Width = 1332
End
Begin VB.Label Label5
BackColor = &H0080C0FF&
Caption = "Card Type"
BeginProperty Font
Name = "MS Sans Serif"
Size = 7.8
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 252
Left = 120
TabIndex = 11
Top = 240
Width = 1092
End
End
Begin VB.Frame Frame2
BackColor = &H00FFFFC0&
Caption = "Analog to Digital Display"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.6
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2892
Left = 120
TabIndex = 2
Top = 120
Width = 8505
Begin VB.PictureBox Gph2
BackColor = &H0080FFFF&
BeginProperty Font
Name = "MS Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000C0&
Height = 1068
Left = 600
ScaleHeight = 1020
ScaleWidth = 7704
TabIndex = 12
Top = 1680
Width = 7752
End
Begin VB.PictureBox Gph
BackColor = &H0080FFFF&
BeginProperty Font
Name = "MS Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000C0&
Height = 1068
Left = 600
ScaleHeight = 1020
ScaleWidth = 7704
TabIndex = 3
Top = 480
Width = 7752
End
Begin VB.Label Label6
BackColor = &H00FFFFC0&
Caption = "-10"
Height = 252
Left = 120
TabIndex = 16
Top = 2400
Width = 372
End
Begin VB.Label Label4
BackColor = &H00FFFFC0&
Caption = "-10"
Height = 252
Left = 120
TabIndex = 15
Top = 1200
Width = 372
End
Begin VB.Label Label3
BackColor = &H00FFFFC0&
Caption = "10"
Height = 252
Left = 120
TabIndex = 14
Top = 1680
Width = 372
End
Begin VB.Label Label2
BackColor = &H00FFFFC0&
Caption = "10"
Height = 252
Left = 120
TabIndex = 13
Top = 480
Width = 372
End
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 5160
Top = 3120
End
Begin VB.CommandButton Command2
Caption = "Active"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.6
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 372
Left = 5640
TabIndex = 1
Top = 3120
Width = 1332
End
Begin VB.CommandButton Command1
Caption = "&Exit"
BeginProperty Font
Name = "Arial"
Size = 10.8
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 372
Left = 7200
TabIndex = 0
Top = 3120
Width = 1332
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const DataNo = 100
Dim fBuf(0 To DataNo * 2 - 1) As Single
Dim wRtn As Integer, wTotalBoards As Integer
Dim wCardType As Integer
Dim bProcessing As Boolean
Private Sub cbCardType_Click()
wCardType = cbCardType.ListIndex
End Sub
Private Sub Command1_Click()
A823_DriverClose
Timer1.Enabled = False
End
End Sub
Private Sub Command2_Click()
Dim wRtn As Integer
If Command2.Caption = "Active" Then
If A823_ActiveBoard(Val(eSelect.Text)) <> A823_NoError Then
MsgBox "Can not Active the Board."
Exit Sub
End If
Gph.Scale (0, 10)-(DataNo, -10)
Gph2.Scale (0, 10)-(DataNo, -10)
A823_ChScan_Clear
wRtn = A823_ChScan_Add(2, 0) ' Channel 2, Config 0
If wRtn <> A823_NoError Then
MsgBox "Fail to add channel!!"
Exit Sub
End If
wRtn = A823_ChScan_Add(0, 0) ' Channel 0, Config 0
If wRtn <> A823_NoError Then
MsgBox "Fail to add channel!!"
Exit Sub
End If
Command2.Caption = "Stop"
Command1.Enabled = False
bProcessing = False
Timer1.Enabled = True
Else
Timer1.Enabled = False
Command2.Caption = "Active"
Command1.Enabled = True
End If
End Sub
Private Sub Form_Load()
Dim rtn
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
'********************************************************************
'* NOTICE: call A823_DriverInit() to initialize the driver. *
'* Initial the device driver, and return the board number in the PC *
'********************************************************************
Command2.Caption = "Active"
Command2.Enabled = False
wRtn = A823_DriverInit(wTotalBoards)
If wRtn <> A823_NoError Then
MsgBox "Can not initial Device Driver!!!"
Exit Sub
End If
If wTotalBoards < 1 Then
MsgBox "Card Not Found!!"
Exit Sub
End If
eTotal.Text = Str(wTotalBoards)
Command2.Enabled = True
cbCardType.ListIndex = 0
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
If bProcessing = True Then
Exit Sub
Else
bProcessing = True
End If
wCardType = cbCardType.ListIndex
wRtn = A823_ChScan_PollingFloat(wCardType, fBuf(0), DataNo)
If wRtn <> A823_NoError Then
Command2_Click
MsgBox "A823_ChScan_PollingFloat() Error!"
bProcessing = False
Exit Sub
End If
' ==========
Gph.Cls
Gph.PSet (0, fBuf(0))
For i = 1 To DataNo - 1
Gph.Line -(i, fBuf(i))
DoEvents
Next i
' ==========
Gph2.Cls
Gph2.PSet (0, fBuf(DataNo))
For i = 1 To DataNo - 1
Gph2.Line -(i, fBuf(i + DataNo))
DoEvents
Next i
bProcessing = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -