VB串口通信中MSComm1.InputMode = comInputModeBinary '二进制方式怎么改成十六进制方式

2024-11-11 14:22:52
推荐回答(1个)
回答1:

MSComm1.InputMode = comInputModeText;//文本方式 Dim recive(1 To 5) As Byte Dim send() As Byte send = MSComm1.Input '---接受 MSComm1.InputMode = comInputModeBinary '---二进制方式发送 MSComm1.Output = recive ' ----发送数据 Do Until MSComm1.InBufferCount >= 5 '-----等待数据 DoEvents Loop Dim i As Integer Dim s As String For i = 0 To UBound(send) s = s & Hex(send(i)) '----十六进制表示 Next i MsgBox "收到5字节:" & s