VB6.0程序运行后两个label1读取的都是仪表的第一行,另一个label2不能读取仪表的第二行,应该怎么办?
DimcaijiAsBoolean'采集状态标志DimshezhizhiAsLong'设置值DimiAsInteger'轮循采集仪表代号PrivateSubMSComm1...
Dim caiji As Boolean '采集状态标志
Dim shezhizhi As Long '设置值
Dim i As Integer '轮循采集仪表代号
Private Sub MSComm1_OnComm()
Dim cmdin() As Byte '接收数据字节变量
Dim HIAL(6) As Single
Dim a As Byte
Dim data1 As String
Dim j, num As Integer
Select Case MSComm1.CommEvent
Case comEvReceive
If MSComm1.InBufferCount = 10 Then
cmdin = MSComm1.Input
For j = 0 To 9
data1 = data1 & " " & cmdin(j)
Next j
HIAL(a) = TwoBytes(cmdin(0), cmdin(1))
Label1.Caption = HIAL(a)
Label2.Caption = HIAL(a)
End If
End Select
End Sub 展开
Dim shezhizhi As Long '设置值
Dim i As Integer '轮循采集仪表代号
Private Sub MSComm1_OnComm()
Dim cmdin() As Byte '接收数据字节变量
Dim HIAL(6) As Single
Dim a As Byte
Dim data1 As String
Dim j, num As Integer
Select Case MSComm1.CommEvent
Case comEvReceive
If MSComm1.InBufferCount = 10 Then
cmdin = MSComm1.Input
For j = 0 To 9
data1 = data1 & " " & cmdin(j)
Next j
HIAL(a) = TwoBytes(cmdin(0), cmdin(1))
Label1.Caption = HIAL(a)
Label2.Caption = HIAL(a)
End If
End Select
End Sub 展开
1个回答
展开全部
HIAL(a) = TwoBytes(cmdin(0), cmdin(1))
Label1.Caption = HIAL(a)
Label2.Caption = HIAL(a)
上述代码中的HIAL(a) ,下标a的值是几?
Label1.Caption = HIAL(a)
Label2.Caption = HIAL(a)
上述代码中的HIAL(a) ,下标a的值是几?
更多追问追答
追问
仪表设置是几就是几,手动改,我应该怎么改??我现在改成这样,但读取的数不对,应该怎么弄?代码其余不变:
Dim a, b As Byte
HIAL(a) = TwoBytes(cmdin(0), cmdin(1))
Label1.Caption = HIAL(a)
HIAL(b) = TwoBytes(cmdin(8), cmdin(4))
Label2.Caption = HIAL(b)
追答
a必须是具体的数值,如你代码那样写,只能是0,即HIAL(0) = TwoBytes(cmdin(0), cmdin(1))
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询