Dim recstr As String
recstr = ""
With MSComm1
Select Case .CommEvent '判断MSComm1通讯事件
Case comEvReceive '收到Rthreshold字节产生的事件
recstr = recstr + .Input '读取一个接受直接
If Trim(Me.Text1.Text) = "" Then
recstr = recstr + .Input
Me.Text1.Text =Me.Text1.Text + recstr
If .PortOpen = False Then
.PortOpen = True
If Err Then
MsgBox "Open Com Port Error!"
'TXTERR.Caption = "Open Com Port Error!"
OpenPort = False
On Error GoTo 0
Exit Function
End If
End If
End With
OpenPort = True
On Error GoTo 0
End Function