📄 jbdz.frm
字号:
VERSION 5.00
Begin VB.Form JBDZ
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 3060
ClientTop = 3345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
Begin VB.CommandButton Command1
Caption = "end"
Height = 375
Left = 3240
TabIndex = 6
Top = 2520
Width = 1095
End
Begin VB.CommandButton JB_DU
Caption = "静标读数"
Height = 375
Left = 3240
TabIndex = 2
Top = 960
Width = 1095
End
Begin VB.CommandButton JB_QUE
Caption = "参数设定"
Height = 375
Left = 3240
TabIndex = 1
Top = 120
Width = 1095
End
Begin VB.CommandButton JB_JUP
Caption = "下一步"
Height = 375
Left = 3240
TabIndex = 0
Top = 1800
Width = 1095
End
Begin VB.Label Label_ZHI
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 375
Left = 1080
TabIndex = 5
Top = 1320
Width = 1575
End
Begin VB.Label Label2
Caption = "静标值:"
Height = 255
Left = 360
TabIndex = 4
Top = 1440
Width = 735
End
Begin VB.Label Label1
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "Label1"
Height = 615
Left = 360
TabIndex = 3
Top = 480
Width = 2775
End
End
Attribute VB_Name = "JBDZ"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
Label1.Caption = "如果静标,请输入信号!"
TX.MSComm1.PortOpen = True
End Sub
Private Sub JB_DU_Click()
Dim inData() As Byte
Dim jbData1(1 To 60) As Long, jbData2(1 To 30) As Long, jbData3(1 To 10) As Long, jbData As Long
Dim dstart%, i%, T As Long
Dim outData1(1 To 1) As Byte
Label1.Caption = " 请稍候..."
jbData = 0
For j = 1 To 10 '读10次
outData1(1) = 155
TX.MSComm1.Output = outData1
Do
DoEvents
Loop Until TX.MSComm1.InBufferCount >= 60 '一次读30个数
inData = TX.MSComm1.Input
dstart = LBound(inData)
For i = 1 To 60
jbData1(i) = inData(dstart + i - 1)
Next i
For i = 1 To 30
jbData2(i) = jbData1(2 * i - 1) * 256 + jbData1(2 * i)
Next i
jbData3(j) = 0
For i = 1 To 30
jbData3(j) = jbData3(j) + jbData2(i)
Next i
jbData3(j) = jbData3(j) / 30 '30个数平均
Label_ZHI.Caption = jbData3(j)
jbData = jbData + jbData3(j)
T = GetTickCount
Do
DoEvents
Loop Until GetTickCount - T >= 500 '每次读数相隔500ms
Next j
jbData = jbData / 10 '10个平均数再平均
Label_ZHI.Caption = jbData
Label1.Caption = "读数完毕"
JB_JUP.Enabled = True
JB_QUE.Enabled = True
End Sub
Private Sub JB_JUP_Click()
Dim outData1(1 To 1) As Byte
Dim inData() As Byte
Dim dstart%
outData1(1) = 156
TX.MSComm1.Output = outData1
For i = 1 To 1000
Next i
TX.MSComm1.PortOpen = False
WAIT.Visible = True
Unload JBDZ
End Sub
Private Sub JB_QUE_Click()
Dim outData1(1 To 1) As Byte
outData1(1) = 157
TX.MSComm1.Output = outData1
For i = 1 To 1000
Next i
TX.MSComm1.PortOpen = False
CSSD.Visible = True
Unload JBDZ
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -