vb中mscomm控件接受数据的问题
小弟使用vb的MSCOMM控件编一个通讯软件,在与下位机进行调试的时候,报错:run-timeerror'28'outofstackspace我的MSCOMM控件的相关代...
小弟使用vb的MSCOMM控件编一个通讯软件,在与下位机进行调试的时候,报错:run-time error '28' out of stack space
我的MSCOMM控件的相关代码如下:
Select Case mainform.MSComm1.CommEvent
Case comEvCD
Case comEvCTS
Case comEvDSR
Case comEvRing
Case comEvReceive
ls = 0
Text4.Text = ""
Text2.Text = ""
Frame4.Caption = "对应名为:"
Dim InByte, i As Integer
Dim buf As String
Dim buf2 As String
t = GetTickCount()
Do
********** DoEvents
Loop Until GetTickCount - t > 100
If ls = 1 Then
Exit Sub
End If
ls = ls + 1
InByte = MSComm1.Input
For i = 0 To UBound(InByte)
If Len(Hex(InByte(i))) = 1 Then
buf2 = "0" & Hex(InByte(i))
Else
buf2 = Hex(InByte(i))
End If
buf = buf & buf2 & " "
Next i
Text2.Text = Text2.Text & buf '接受的数据以十六进制表示在文本框中
Call tq(Text2.Text)
Call zh(name1)
Frame4.Caption = Frame4.Caption & Trim(S)
Call cl(Text2.Text)
Call zh(a3)
Text4.Text = Trim(S)
If InStr(Text4.Text, "R111") Then
Call cx(Text4.Text)
Call send(name1)
Else
MsgBox "没相应命令~!"
End If
End Select
报错指向*号处,,不知哪位能帮忙解决下啊??????
能告诉下要怎么修改才能避免出现这个错误么?谢谢了。。。 展开
我的MSCOMM控件的相关代码如下:
Select Case mainform.MSComm1.CommEvent
Case comEvCD
Case comEvCTS
Case comEvDSR
Case comEvRing
Case comEvReceive
ls = 0
Text4.Text = ""
Text2.Text = ""
Frame4.Caption = "对应名为:"
Dim InByte, i As Integer
Dim buf As String
Dim buf2 As String
t = GetTickCount()
Do
********** DoEvents
Loop Until GetTickCount - t > 100
If ls = 1 Then
Exit Sub
End If
ls = ls + 1
InByte = MSComm1.Input
For i = 0 To UBound(InByte)
If Len(Hex(InByte(i))) = 1 Then
buf2 = "0" & Hex(InByte(i))
Else
buf2 = Hex(InByte(i))
End If
buf = buf & buf2 & " "
Next i
Text2.Text = Text2.Text & buf '接受的数据以十六进制表示在文本框中
Call tq(Text2.Text)
Call zh(name1)
Frame4.Caption = Frame4.Caption & Trim(S)
Call cl(Text2.Text)
Call zh(a3)
Text4.Text = Trim(S)
If InStr(Text4.Text, "R111") Then
Call cx(Text4.Text)
Call send(name1)
Else
MsgBox "没相应命令~!"
End If
End Select
报错指向*号处,,不知哪位能帮忙解决下啊??????
能告诉下要怎么修改才能避免出现这个错误么?谢谢了。。。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询