📄 counter.frm
字号:
VERSION 5.00
Object = "{4E2051E6-9099-11D2-A9D2-002018650913}#1.1#0"; "Adcounter.ocx"
Begin VB.Form DAQForm
BorderStyle = 3 'Fixed Dialog
Caption = "计数器输入"
ClientHeight = 3420
ClientLeft = 45
ClientTop = 435
ClientWidth = 6075
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3420
ScaleWidth = 6075
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer2
Enabled = 0 'False
Interval = 100
Left = 5400
Top = 2880
End
Begin VB.CommandButton CmdFrequency
Caption = "开始计频"
Height = 405
Left = 4680
TabIndex = 7
Top = 1500
Width = 1155
End
Begin VB.Frame Frame2
Caption = "频率值"
Height = 1455
Left = 240
TabIndex = 5
Top = 1800
Width = 4095
Begin VB.TextBox Tfrequency
Alignment = 2 'Center
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 1080
TabIndex = 6
Top = 480
Width = 1875
End
End
Begin VB.CommandButton CmdCounter
Caption = "开始计数"
Height = 405
Left = 4680
TabIndex = 4
Top = 720
Width = 1155
End
Begin VB.CommandButton Cmdclose
Caption = "关闭程序"
Height = 405
Left = 4680
TabIndex = 3
Top = 2280
Width = 1155
End
Begin VB.Frame Frame1
Caption = "计数值"
Height = 1455
Left = 240
TabIndex = 1
Top = 240
Width = 4095
Begin VB.TextBox TCounter
Alignment = 2 'Center
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 1080
TabIndex = 2
Top = 480
Width = 1875
End
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 1000
Left = 4680
Top = 2880
End
Begin DAQCounterLib.DAQCounter DAQCounter1
Height = 495
Left = 5280
TabIndex = 0
Top = 120
Width = 495
_Version = 65537
_ExtentX = 864
_ExtentY = 864
_StockProps = 0
ErrorCode = 10002
ErrorMessage = "The OpenDevice method must be called before performing any I/O operations."
PresetValue = 0
WatchdogTime = 0
WatchdogEnabled = 0 'False
End
End
Attribute VB_Name = "DAQForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'板卡设置
Private Sub Form_Load()
DAQCounter1.SelectDevice '选择板卡设备
DAQCounter1.Channel = 0 '指定计数器通道号0
DAQCounter1.Direction = Up '计数器向上累加计数
DAQCounter1.GateMode = 0 '无触发
End Sub
'开始计数
Private Sub CmdCounter_Click()
DAQCounter1.OpenDevice '打开设备
DAQCounter1.PresetValue = 0 '计数器开始计数时的起始值
DAQCounter1.EnableCounter True '使计数器的计数功能有效
DAQCounter1.EnableFrequency False '使计数器的计频功能无效
Timer1.Enabled = True
Timer2.Enabled = False '停止计频
End Sub
'开始计频
Private Sub CmdFrequency_Click()
DAQCounter1.OpenDevice '打开设备
DAQCounter1.EnableFrequency True '使计数器的计频功能有效
DAQCounter1.EnableCounter False '使计数器的计数功能无效
Timer2.Enabled = True
Timer1.Enabled = False '停止计数
End Sub
'计数
Private Sub Timer1_Timer()
TCounter.Text = DAQCounter1.CounterValue '获得计数值
End Sub
'计频
Private Sub Timer2_Timer()
Tfrequency.Text = Format$(DAQCounter1.FrequencyValue, "0") '获得频率值
End Sub
'退出程序
Private Sub Cmdclose_Click()
DAQCounter1.ResetCounter '停止计数计频功能
DAQCounter1.CloseDevice '关闭设备
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -