📄 frmintdi.frm
字号:
VERSION 5.00
Object = "{B69B88D6-A697-11D2-AA03-002018650913}#1.1#0"; "Addin.ocx"
Begin VB.Form Form1
Caption = "DI with Interrupt"
ClientHeight = 3135
ClientLeft = 60
ClientTop = 345
ClientWidth = 6555
LinkTopic = "Form1"
ScaleHeight = 3135
ScaleWidth = 6555
StartUpPosition = 2 'CenterScreen
Begin VB.Frame Frame3
Caption = "Interrupt Event:"
Height = 1572
Left = 3030
TabIndex = 12
Top = 1440
Width = 3372
Begin VB.Timer WatchTimer
Left = 2640
Top = 960
End
Begin VB.TextBox txtEventFreq
Enabled = 0 'False
Height = 372
Left = 240
TabIndex = 15
Top = 960
Width = 1212
End
Begin VB.CommandButton cmdDisableEvent
Caption = "Disable"
Height = 372
Left = 1920
TabIndex = 14
Top = 360
Width = 1092
End
Begin VB.CommandButton cmdEnableEvent
Caption = "Enable"
Height = 372
Left = 240
TabIndex = 13
Top = 360
Width = 1212
End
Begin VB.Label Label5
Caption = "1/S"
Height = 372
Left = 1560
TabIndex = 16
Top = 1080
Width = 372
End
End
Begin VB.Frame Frame2
Caption = "Device Property:"
Height = 1572
Left = 110
TabIndex = 7
Top = 1440
Width = 2772
Begin VB.HScrollBar hscrlCount
Height = 252
Left = 120
Max = 10
Min = 1
TabIndex = 9
Top = 480
Value = 1
Width = 2512
End
Begin VB.Label Label4
Caption = "10"
Height = 375
Left = 2190
TabIndex = 11
Top = 720
Width = 375
End
Begin VB.Label Label8
Caption = "1"
Height = 252
Left = 380
TabIndex = 10
Top = 720
Width = 252
End
Begin VB.Label Label3
Caption = "EventTrigCount:"
Height = 252
Left = 120
TabIndex = 8
Top = 240
Width = 1332
End
End
Begin DAQDILib.DAQDI DAQDI1
Height = 495
Left = 5520
TabIndex = 17
Top = 240
Width = 495
_Version = 65537
_ExtentX = 864
_ExtentY = 864
_StockProps = 0
MaxPortNumber = 0
End
Begin VB.CommandButton cmdExit
Caption = "Close"
Height = 405
Left = 5160
TabIndex = 6
Top = 900
Width = 1212
End
Begin VB.Frame Frame1
Caption = "Select Device :"
Height = 1215
Left = 110
TabIndex = 0
Top = 120
Width = 4935
Begin VB.CommandButton cmdSelectDevice
Caption = "&Select Device"
Default = -1 'True
Height = 375
Left = 3240
TabIndex = 3
ToolTipText = "Selecting device to operation"
Top = 240
Width = 1455
End
Begin VB.TextBox txtDeviceName
Height = 305
Left = 1320
TabIndex = 2
Text = "AdvanTech"
ToolTipText = "Device Name"
Top = 745
Width = 3375
End
Begin VB.TextBox txtDeviceNum
Height = 285
Left = 1320
TabIndex = 1
Text = "-100"
ToolTipText = "Device Number"
Top = 350
Width = 855
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "Device Name :"
Height = 195
Left = 120
TabIndex = 5
Top = 765
Width = 1065
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Device No. :"
Height = 195
Left = 120
TabIndex = 4
Top = 405
Width = 900
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim gEventCount As Long
Private Sub cmdDisableEvent_Click()
'Disable Event
DAQDI1.EnableEvent (False)
' Close device
DAQDI1.CloseDevice
'Disable watch timer
WatchTimer.Enabled = False
cmdSelectDevice.Enabled = True
cmdEnableEvent.Enabled = True
cmdDisableEvent.Enabled = False
cmdExit.Enabled = True
End Sub
Private Sub cmdEnableEvent_Click()
'Open Device
If DAQDI1.OpenDevice Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
'Enable Event
If (DAQDI1.EnableEvent(True)) Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
cmdSelectDevice.Enabled = False
cmdEnableEvent.Enabled = False
cmdDisableEvent.Enabled = True
cmdExit.Enabled = False
'Enable watch timer
WatchTimer.Enabled = True
End Sub
Private Sub cmdExit_Click()
Unload Me
End
End Sub
Private Sub cmdSelectDevice_Click()
Dim i As Integer
Dim Ret As Long
' Select Device from installed list
Ret = DAQDI1.SelectDevice
txtDeviceNum.Text = DAQDI1.DeviceNumber
txtDeviceName.Text = DAQDI1.DeviceName
DAQDI1.DeviceNumber = DAQDI1.DeviceNumber
DAQDI1.DeviceName = DAQDI1.DeviceName
End Sub
Private Sub DAQDI1_OnEvent()
gEventCount = gEventCount + 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
DAQDI1.EnableEvent (False)
DAQDI1.CloseDevice
WatchTimer.Enabled = False
End Sub
Private Sub hscrlCount_Change()
DAQDI1.EventTrigCount = hscrlCount.Value
End Sub
Private Sub txtDeviceNum_Change()
DAQDI1.DeviceNumber = Val(txtDeviceNum.Text)
txtDeviceName.Text = DAQDI1.DeviceName
End Sub
Private Sub Form_Load()
' Select default device
Call cmdSelectDevice_Click
' Setting initial value
txtDeviceNum.Text = DAQDI1.DeviceNumber
txtDeviceName.Text = DAQDI1.DeviceName
'Initialize global value
gEventCount = 0
WatchTimer.Enabled = False
WatchTimer.Interval = 1000
cmdEnableEvent.Enabled = True
cmdDisableEvent.Enabled = False
End Sub
Private Sub WatchTimer_Timer()
txtEventFreq.Text = Str(gEventCount)
gEventCount = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -