vb 串口接收为什么不能显示数据啊

来源:百度知道 编辑:UC知道 时间:2024/06/06 12:41:17
vb,RS-232c对cs-1000a进行串口编程,能发但为什么不能显示接收到的数据啊,哪位能否指点一下.下面是我的程序
Private Sub Command1_Click()
' MSComm1.OutBufferCount = 0
MSComm1.Output = Text1.Text + Chr$(13) + Chr$(10)

End Sub

Private Sub Form_Load()
With MSComm1
.CommPort = 1
.Settings = "9600,n,8,1"
.InBufferCount = 0
.InBufferSize = 512
.OutBufferCount = 0
.OutBufferSize = 512
.RThreshold = 1
.SThreshold = 1

If Not .PortOpen Then
.PortOpen = True
End If
End With
End Sub

Private Sub MSComm1_OnComm()
Dim temp As Variant
Dim Okstring As String
Select Case MSComm1.CommEvent
Case comEvReceive
MSComm1.InputLen = 0
temp = MSComm1.Input
Okstring = temp
Text2.Text = Text2.Text + temp
End Select
MSComm1.OutBufferCount = 0<

你的程序没有错误,发和接受在字符串的时候都可以接受,
你首先看看cs-1000a发送给上位机的是 格式 16进制?ascii?这个你要弄清楚,通信协议设置是对的吗?最好通信之前用串口调试精灵 测试一下!