下面一段程序,可能对你有用
private sub send
dim cmd as string
cmd="ok,request data"
mscomm1.output=cmd
timer.enable=true
end sub
Private Sub Timer1_Timer() 延时读取
If Me.MSComm1.InBufferCount > 0 Then
MSComm1_OnComm
End If
Me.Timer1.Enabled = False
End Sub
Private Sub MSComm1_OnComm()接收数据
Dim recstr As String
If Me.MSComm1.InBufferCount > 0 Then
recstr = Me.MSComm1.Input
End If
End Sub
通信程序应该采用多线程
用定时器至少也有50ms的延时,你可以调用Win32API实现延时
我来先给出Delphi源程序,有问是可以我QQ39161700联系
procedure TimeDelay(DT:DWORD);
var
TT:DWORD;
begin
TT:=GetTickCount();
While (GetTickCount()-TT)<DT do
Application.ProcessMessages;
end;