使用vb编一个读写2进制的数 并在text上显示
PrivateSubCommand2_Click()Dimsendmsg(5)AsByteDimrcvdat()AsByteDimdattmpAsVariantDimiA...
Private Sub Command2_Click()
Dim sendmsg(5) As Byte
Dim rcvdat() As Byte
Dim dattmp As Variant
Dim i As Integer
Command2.Enabled = False
For i = 0 To 5
sendmsg(i) = "&h" & Mid(Text2.Text, i * 2 + 1, 2)
Next i
MSComm1.PortOpen = True
MSComm1.Output = sendmsg
Do Until MSComm1.InBufferCount >= 6
DoEvents
Loop
dattmp = MSComm1.Input
rcvdat = dattmp
Text1.Text = " "
For i = 0 To 5
Text1.Text = Text1.Text & Right("0" & Hex(rcvdat(i)), 2)
Next i
MSComm1.PortOpen = False
Command2.Enabled = True
End Sub
这是代码 可是编译有错:类型不匹配 第六行
问题解决追加高分!
希望高手帮我一把 qq 78162776 在线等!
回答1楼:还是实时错误:类型不匹配! 展开
Dim sendmsg(5) As Byte
Dim rcvdat() As Byte
Dim dattmp As Variant
Dim i As Integer
Command2.Enabled = False
For i = 0 To 5
sendmsg(i) = "&h" & Mid(Text2.Text, i * 2 + 1, 2)
Next i
MSComm1.PortOpen = True
MSComm1.Output = sendmsg
Do Until MSComm1.InBufferCount >= 6
DoEvents
Loop
dattmp = MSComm1.Input
rcvdat = dattmp
Text1.Text = " "
For i = 0 To 5
Text1.Text = Text1.Text & Right("0" & Hex(rcvdat(i)), 2)
Next i
MSComm1.PortOpen = False
Command2.Enabled = True
End Sub
这是代码 可是编译有错:类型不匹配 第六行
问题解决追加高分!
希望高手帮我一把 qq 78162776 在线等!
回答1楼:还是实时错误:类型不匹配! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询