Difference between revisions of "Serial.SerialPort"

From Xojo Documentation

m
m (Example)
Line 12: Line 12:
 
==Example==
 
==Example==
  
This example is in the Open event of the main window of the Line State Change Tester app. It populates the popup menu of the serial ports available on the user’s computer.
+
The code below is from Examples/Communication/Serial/Line State Change Tester:
  
 
<rbcode>
 
<rbcode>
 
   ' Populate the popup menu with all of the
 
   ' Populate the popup menu with all of the
 
   ' serial ports the system has installed.
 
   ' serial ports the system has installed.
   dim i, count as Integer
+
   Dim count As Integer
 
   count = System.SerialPortCount
 
   count = System.SerialPortCount
 
    
 
    
   for i = 0 to count - 1
+
   For i As Integer = 0 To count - 1
     PopupMenu1.AddRow( System.SerialPort( i ).Name )
+
     PopupMenu1.AddRow(System.SerialPort(i).Name)
   next
+
   Next
 
</rbcode>
 
</rbcode>

Revision as of 14:11, 14 November 2016

Property (As SerialPort )
aSerial.SerialPort = newSerialPortValue
or
SerialPortValue = aSerial.SerialPort

Supported for all project types and targets.

Used to identify the serial port to which the Serial control will communicate.

Example

The code below is from Examples/Communication/Serial/Line State Change Tester:

' Populate the popup menu with all of the
' serial ports the system has installed.
Dim count As Integer
count = System.SerialPortCount

For i As Integer = 0 To count - 1
PopupMenu1.AddRow(System.SerialPort(i).Name)
Next