MSComm控件的奇怪问题????
使用超级终端可以很好的访问COM口,但是在VB6中用MSComm控件,输入命令后发现inputBufferCount的值不为0,但是用input读取时总是出错!!请问是什么原因呀?
谢谢各位,在线等待,解决问题马上揭帖!!!!
问题点数:100、回复次数:7Top
1 楼gcj123(佛的光辉)回复于 2003-09-04 15:00:08 得分 10
代码怎样,提示怎样的错误Top
2 楼flowercat(小强)回复于 2003-09-04 15:17:15 得分 0
我设置了On Error GoTo ErrHandler:
只要一运行到input时,就跳到了ErrHandler处理。
On Error GoTo ErrHandler:
MSComm1.CommPort = Port
MSComm1.Settings = Settings
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
MSComm1.Output = "AT" + Chr$(13) + Chr$(10)
MSComm1.InputLen = 0
Do
DoEvents
temp$ = MSComm1.Input
Loop Until InStr(temp$, "OK")
setConnection = True
RaiseEvent addQueueStatus("连接成功!")
End If
ErrHandler:
If MSComm1.PortOpen = False Then
setConnection = False
RaiseEvent addQueueStatus("连接失败!")
Else: Timer3.Enabled = True
Timer4.Enabled = True
End IfTop
3 楼flowercat(小强)回复于 2003-09-04 16:52:26 得分 0
UPTop
4 楼yijiansong(不知路在何方)回复于 2003-09-04 17:11:38 得分 20
提示怎样的错误
Top
5 楼gcj123(佛的光辉)回复于 2003-09-04 17:31:40 得分 30
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
MSComm1.Output = "AT" + Chr$(13) + Chr$(10)
MSComm1.InputLen = 0
Do
DoEvents
temp$ = MSComm1.Input
Loop Until InStr(temp$, "OK")
setConnection = True
RaiseEvent addQueueStatus("连接成功!")
End If
改成
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
MSComm1.InputLen = 0
MSComm1.Output = "AT" + Chr$(13) + Chr$(10)
Do
DoEvents
temp$ = temp$ & MSComm1.Input
Loop Until InStr(temp$, "OK")
setConnection = True
RaiseEvent addQueueStatus("连接成功!")
End If
Top
6 楼gcj123(佛的光辉)回复于 2003-09-04 17:34:12 得分 30
不好意思,最好改成
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
MSComm1.InputLen = 0
MSComm1.Output = "AT" + Chr$(13) + Chr$(10)
Do
DoEvents
if mscomm1.inputlen>0 then temp$ = temp$ & MSComm1.Input
Loop Until InStr(temp$, "OK")
setConnection = True
RaiseEvent addQueueStatus("连接成功!")
End IfTop
7 楼LeoUltraman(King)回复于 2003-09-04 17:34:30 得分 10
the port is not closedTop



