📄 di.frm
字号:
VERSION 5.00
Object = "{B69B88D6-A697-11D2-AA03-002018650913}#1.1#0"; "Addin.ocx"
Begin VB.Form DAQForm
BorderStyle = 3 'Fixed Dialog
Caption = "数字量输入"
ClientHeight = 3495
ClientLeft = 45
ClientTop = 330
ClientWidth = 3885
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3495
ScaleWidth = 3885
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "状态显示"
Height = 2310
Left = 135
TabIndex = 2
Top = 135
Width = 3615
Begin VB.TextBox Tnum
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 2070
TabIndex = 3
Top = 990
Width = 870
End
Begin VB.Shape Alarm
FillColor = &H0000FF00&
FillStyle = 0 'Solid
Height = 1050
Left = 495
Shape = 3 'Circle
Top = 720
Width = 870
End
End
Begin DAQDILib.DAQDI DAQDI1
Height = 495
Left = 225
TabIndex = 1
Top = 2790
Width = 495
_Version = 65537
_ExtentX = 864
_ExtentY = 864
_StockProps = 0
MaxPortNumber = 0
ScanTime = 500
End
Begin VB.CommandButton Cmdquit
Caption = "关闭程序"
Height = 465
Left = 1395
TabIndex = 0
Top = 2790
Width = 1095
End
Begin VB.Timer Timer1
Interval = 500
Left = 810
Top = 2835
End
End
Attribute VB_Name = "DAQForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义变量
Dim num As Integer
Dim bz As Integer
'初始化
Private Sub Form_Load()
bz = 1
Alarm.FillColor = QBColor(10)
DAQDI1.SelectDevice
DAQDI1.OpenDevice
DAQDI1.ScanTime = 500 '数字量输入扫描时段(毫秒)
End Sub
'周期检测数字量输入端口状态
Private Sub Timer1_Timer()
Dim zt1 As String
Dim zt2 As String
'数字量输入0通道
DAQDI1.Port = 0 '数字量输入0端口
DAQDI1.Bit = 0 '数字量输入0端口第0位
zt1 = DAQDI1.BitInput '数字量输入0端口第0位的状态
If zt1 = "True" Then
Alarm.FillColor = QBColor(10)
Else
Alarm.FillColor = QBColor(12)
End If
'数字量输入1通道
DAQDI1.Port = 0 '数字量输入0端口
DAQDI1.Bit = 1 '数字量输入0端口第1位
zt2 = DAQDI1.BitInput '数字量输入0端口第1位的状态
If zt2 = "False" And bz = 1 Then
num = num + 1
Tnum.Text = Str$(num)
bz = 2
End If
If zt2 = "True" Then
bz = 1
End If
End Sub
'关闭程序
Private Sub Cmdquit_Click()
DAQDI1.CloseDevice
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -