VB中MSComm控件怎么一次性把数组发出去? 100
长话短说:我用以下代码就不能实现,必须要按8次按钮才能发送完:PrivateSubCommand2_Click()DimaAsIntegerDimTiData(8)AsB...
长话短说:我用以下代码就不能实现,必须要按8次按钮才能发送完:
Private Sub Command2_Click()
Dim a As Integer
Dim TiData(8) As Byte
TiData(1) = &HAA
TiData(2) = &HBB
TiData(3) = &HCC
TiData(4) = &HDD
TiData(5) = &HEE
TiData(6) = &HFF
TiData(7) = &H00
TiData(8) = &H11
MSComm1.Output = TiData
End Sub
然后改成这样才行:
Private Sub Command2_Click()
Dim a As Integer
Dim TiData(8) As Byte
TiData(1) = &HAA
TiData(2) = &HBB
TiData(3) = &HCC
TiData(4) = &HDD
TiData(5) = &HEE
TiData(6) = &HFF
TiData(7) = &H00
TiData(8) = &H11
For a = 1 To 8
MSComm1.Output = TiData
Next a
End Sub
这是为什么?有什么办法可以一次性把整个数组发出去吗? 展开
Private Sub Command2_Click()
Dim a As Integer
Dim TiData(8) As Byte
TiData(1) = &HAA
TiData(2) = &HBB
TiData(3) = &HCC
TiData(4) = &HDD
TiData(5) = &HEE
TiData(6) = &HFF
TiData(7) = &H00
TiData(8) = &H11
MSComm1.Output = TiData
End Sub
然后改成这样才行:
Private Sub Command2_Click()
Dim a As Integer
Dim TiData(8) As Byte
TiData(1) = &HAA
TiData(2) = &HBB
TiData(3) = &HCC
TiData(4) = &HDD
TiData(5) = &HEE
TiData(6) = &HFF
TiData(7) = &H00
TiData(8) = &H11
For a = 1 To 8
MSComm1.Output = TiData
Next a
End Sub
这是为什么?有什么办法可以一次性把整个数组发出去吗? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询