efesotomasyon.com
E6581315
3)The description of the code
Private Sub Form_Load()
Form1.Show
'**********************************************************************
'Setting the labels (Initialization) '**********************************************************************
Label1.Caption = "Data for transmission" Label2.Caption = "Received data" Command1.Caption = "Transmit" Command2.Caption = "Clear" Command3.Caption = "Exit"
'**********************************************************************
'Setup of communication (Initialization) '**********************************************************************
MSComm1.RThreshold = 0 MSComm1.InputLen = 1 MSComm1.CommPort = 1 MSComm1.InBufferCount = 0 MSComm1.OutBufferCount = 0 Form1.MSComm1.Settings = "9600,E,8,1" Form1.MSComm1.InputMode = comInputModeText
'**********************************************************************
'A serial port is opened. (Initialization) '**********************************************************************
If False = MSComm1.PortOpen Then MSComm1.PortOpen = True
End If
'**********************************************************************
'Data are received. '**********************************************************************
Do
dummy = DoEvents()
If MSComm1.InBufferCount Then Text1.Text = Text1.Text & MSComm1.Input
End If Loop
End Sub
'**********************************************************************
'The contents of the text box are transmitted. '********************************************************************** Private Sub Command1_Click()
MSComm1.Output = Text2.Text & Chr(13)
End Sub
'********************************************************************** 'The contents of the text box are removed. '********************************************************************** Private Sub Command2_Click()
Text2.Text = ""
Text1.Text = "" End Sub
'********************************************************************** 'A serial port is closed, end '********************************************************************** Private Sub Command3_Click()
If True = MSComm1.PortOpen Then
MSComm1.PortOpen = False End If
End End Sub
28