var recstr:Olevariant; i:integer; begin if Mscomm1.CommEvent = 2 then begin repeat i := MSComm1.InBufferCount; Sleep (200); //'API 函数,挂起当前进程一段时间 Until MSComm1.InBufferCount = i; recstr := MSComm1.Input; // showmessage( recstr); self.CheckFileEx ; try self.ReadstrFromCom(recstr) except on EconvertError do Application.MessageBox('条码识读出错。','提示',64); end; end; 把这段译成BASIC就行了,这段是我从BASIC中转过去的.一定行. 这是我工程中的源码,没问题的 .
做个全局变量GETSTRPrivate Sub MSComm1_OnComm() Dim i As Integer, b As String Dim Buffer As Variant
'MDIForm1.StatusBar1.Panels(1).Picture = MDIForm1.ImageList1.ListImages(1).Picture i = MSComm1.CommEvent If i > 1000 Then If i = 1001 Then b = "接受到一个中断信号!" If i = 1002 Then b = "Clear To Send 超时!" If i = 1003 Then b = "Date Set Ready 超时!" If i = 1004 Then b = "通讯帧错误!" If i = 1006 Then b = "端口超速!" If i = 1007 Then b = "载波检测超时!" If i = 1008 Then b = "接受缓冲区溢出!" If i = 1009 Then b = "奇偶校验错误!" If i = 1010 Then b = "传送缓冲区溢出!" If i = 1011 Then b = "检测端口设备控制块DCB错误!" Else If i = 2 Then Form5.Label3(0).BackColor = QBColor(2) Buffer = MSComm1.Input getstr = getstr + StrConv(Buffer, vbUnicode) Form5.Label3(0).BackColor = 0 End If If i = 3 Then b = "检波状态改变" End If 'MDIForm1.StatusBar1.Panels(1).Picture = MDIForm1.ImageList1.ListImages(2).Picture If b <> "" Then addtip 2, 1, b End Sub
定时查看mscomm1.input属性。
recstr:Olevariant;
i:integer;
begin
if Mscomm1.CommEvent = 2 then
begin repeat
i := MSComm1.InBufferCount;
Sleep (200); //'API 函数,挂起当前进程一段时间 Until MSComm1.InBufferCount = i; recstr := MSComm1.Input;
// showmessage( recstr);
self.CheckFileEx ;
try
self.ReadstrFromCom(recstr)
except
on EconvertError do Application.MessageBox('条码识读出错。','提示',64);
end;
end;
把这段译成BASIC就行了,这段是我从BASIC中转过去的.一定行.
这是我工程中的源码,没问题的 .
Dim i As Integer, b As String
Dim Buffer As Variant
'MDIForm1.StatusBar1.Panels(1).Picture = MDIForm1.ImageList1.ListImages(1).Picture
i = MSComm1.CommEvent
If i > 1000 Then
If i = 1001 Then b = "接受到一个中断信号!"
If i = 1002 Then b = "Clear To Send 超时!"
If i = 1003 Then b = "Date Set Ready 超时!"
If i = 1004 Then b = "通讯帧错误!"
If i = 1006 Then b = "端口超速!"
If i = 1007 Then b = "载波检测超时!"
If i = 1008 Then b = "接受缓冲区溢出!"
If i = 1009 Then b = "奇偶校验错误!"
If i = 1010 Then b = "传送缓冲区溢出!"
If i = 1011 Then b = "检测端口设备控制块DCB错误!"
Else
If i = 2 Then
Form5.Label3(0).BackColor = QBColor(2)
Buffer = MSComm1.Input
getstr = getstr + StrConv(Buffer, vbUnicode)
Form5.Label3(0).BackColor = 0
End If
If i = 3 Then b = "检波状态改变"
End If
'MDIForm1.StatusBar1.Panels(1).Picture = MDIForm1.ImageList1.ListImages(2).Picture
If b <> "" Then addtip 2, 1, b
End Sub