接收不到数据 新手求大虾们支援
Private Sub MSComm1_OnComm()Dim i As Integer
Dim BytReceived() As Byte
Dim strBuff As String
'Dim strData As String
Select Case MSComm1.CommEvent '事件发生
Case comEvReceive
'Cls
'MSComm1.InputMode = comInputModeBinary
'MSComm1.InputLen = 0 读入缓冲区全部内容
BytReceived() = MSComm1.Input 读入到缓冲区
For i = 1 To UBound(BytReceived)
If BytReceived(i) = "55" And BytReceived(i + 1) = "AA" Then
datatemp(num) = Val("&H" & Mid(strBuff, i + 4, 2) & Mid(strBuff, i + 6, 2)) * 0.0625
Label19.Caption = Format$(DatatempFromCom, "0.0")
End If
Next i
End Select
End Sub --------------------编程问答-------------------- 代码不全,无法判断 --------------------编程问答-------------------- 前面main设置的触发oncome时间是MSComm1.RThreshold = 1 调试后
在这句可能有错误For i = 1 To UBound(BytReceived)
If BytReceived(i) = "55" And BytReceived(i + 1) = "AA" Then
datatemp(num) = Val("&H" & Mid(strBuff, i + 4, 2) & Mid(strBuff, i + 6, 2)) * 0.0625
Label19.Caption = Format$(DatatempFromCom, "0.0")
可能是If 语句有错误 我单片机程序 我用串口调试助手接收的是 55 AA(开始) +数据 +44 BB (结束)但是自己编写的这个 有问题 --------------------编程问答-------------------- strBuff 中的数据来自哪里?
--------------------编程问答-------------------- 哦 忘了发上去~~ strBuff = strBuff & Hex(BytReceived(i)) & chr(32) 获得每一个十六进制数 问题是现在 我到那句就没往下去了 If BytReceived(i) = "%H55" And BytReceived(i + 1) = "&HAA" Then 我用串口助手 接收的 是对的 就是 55 AA + 数据+ 44 BB
--------------------编程问答-------------------- 串口初始化设置,一次性全部接收缓存中的数据.
补充:VB , COM/DCOM/COM+