34
Sample program
'MSCOMM1
Close the port.
Private Sub CloseComm ()
On Error GoTo Exit_CloseComm
With MSComm1
If .PortOpen = True Then
. PortOpen = False
'port close
Call FlashBuffer
'flash of buffer
. RTSEnable = False
. DTREnable = False
End if
End With
ShowLog "CloseComm", "OK"
Exit_CloseComm:
Exit Sub
End Sub
'MSCOMM1
Flash of sending and receiving buffer
Private Sub FlashBuffer ( )
With MSComm1
. InBufferCount = 0
. OutBufferCount = 0
End With
End Sub
'Text1
Log display letters
Private Sub ShowLog(Optional ByVal dat1 As Variant, Optional ByVal dat2 As Variant)
With Text1
If Len(. Text) >= . MaxLength Then . Text = Right(. Text, 256)
. SelStart = Len(. Text)
. SelText = dat1 & ":" & dat2 & vbCrLf
End With
End Sub