读书人

MSComm1.InBufferCount 显示为16但接

发布时间: 2013-09-28 10:01:20 作者: rapoo

MSComm1.InBufferCount 显示为16,但接收后 却没有数据 是怎么回事
'读表命令发送完毕后,等待读表数据返回到串口缓冲区

Dim gs As Long,I as long , VBiaoFanh As Variant
I = 0: J = False:gs=0

Do While I < 200 And J = False
gs = MSComm1.InBufferCount
If gs >= 16 Then
J = True
Exit Do
End If
I = I + 1
Sleep (10)
Loop

VBiaoFanh = MSComm1.Input
当 程序在 gs=16时 继续向下执行的路径为:

If gs >= 16 Then
J = True
Exit Do

VBiaoFanh = MSComm1.Input

但是 VBiaoFanh = MSComm1.Input 执行完后,VBiaoFanh 却没有数据 监视窗口中显示
Watch : - : VBiaoFanh : : Variant/Byte(0 to -1)

这是什么原因呢,明明显示串口接收缓冲区中有16个数据,接收后,却没有数据?


[解决办法]
复制到VB区看看那有没有人知道

读书人网 >单片机

热点推荐