The top-level object of the COM Port UCX component. Reads from and writes to serial ports.
Sets the baud rate on the COM port.
object.BaudRate[=BaudRate As Integer]
Integer.
Read/write.
BaudRate is an optional parameter that sets the COM port's baud rate. Valid values are: 110, 150, 300, 600, 1200, 2400, and 9600.
This example sets the baud rate to 600 for COM1.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
Sets the number of data bits to 7 or 8.
object.DataBits[=Number As Integer]
Integer.
Read/write.
Number is an optional parameter that sets the number of data bits. Valid values are 7 and 8.
This example sets number of data bits to 7 on COM1.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
Sets the parity to even or odd.
object.Parity=[Bit As Integer]
Integer.
Read/write.
Valid Bit parameter values are EVEN and ODD.
This example sets parity to EVEN on COM1.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
Sets the COM port number.
object.Port[=Number As Integer]
Integer.
Read/write.
Number is an optional parameter that
sets the COM port number. See Port
Constants
.
This example sets COM1 as the serial port to use.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
Sets the stop bits value to 1 or 2.
object.StopBits[=Number As Integer]
Integer.
Read/write.
Number is an optional parameter that sets the stop bits value to 1 or 2.
This example sets the stop bits value to 2 on COM1.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
ComObj.StopBits = 2
Sets the serial port to on or off.
object.Xon =Status As Boolean]
Boolean.
Read/write.
Valid Status parameter values are TRUE or FALSE.
This example sets the serial port COM1 to ON.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
ComObj.StopBits = 2
ComObj.Xon = TRUE
Clears the data buffer for a specified serial port.
object.Clear()
None.
Boolean. Returns TRUE if successful; otherwise, FALSE.
This example clears the data buffer for serial port COM1.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
ComObj.StopBits = 2
ComObj.Xon = TRUE
ComObj.Open()
ComObj.Clear()
Closes a specified serial port.
object.Close()
None.
Boolean. Returns TRUE if successful; otherwise, FALSE.
This example closes the serial port COM1.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
ComObj.StopBits = 2
ComObj.Xon = TRUE
ComObj.Open()
ComObj.Clear()
ComObj.Close()
Opens and initializes a specified serial port.
object.Open()
None.
Boolean. Returns TRUE if successful; otherwise, FALSE.
This example opens and initializes the serial port COM1.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
ComObj.StopBits = 2
ComObj.Xon = TRUE
ComObj.Open()
ComObj.Clear()
Reads from a specified serial port.
object.Read ([BytesToRead As Integer])
String.
This example reads one byte from serial port COM1.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
ComObj.StopBits = 2
ComObj.Xon = TRUE
ComObj.Open()
ComObj.Clear()
If(ComObj.Ready()) Then
data = ComObj.Read(1)
EndIf
ComObj.Close()
Determines if a character is in the buffer for a specified serial port and if that character is ready to be read.
object.Ready
None.
Boolean. Returns TRUE if successful; otherwise, FALSE.
This example determines if a character is in the buffer for serial port COM1 and if that characters is ready to be read.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
ComObj.StopBits = 2
ComObj.Xon = TRUE
ComObj.Open()
ComObj.Clear()
ComObj.Write("Once again, Novell leads the way")
If(ComObj.Ready()) Then
data = ComObj.Read(1)
EndIf
ComObj.Close()
Writes a string to a specified serial port.
object.Write (Data As String)
Boolean. Returns TRUE if successful; otherwise, FALSE.
This example writes the text "Once again, Novell leads the way" to serial port COM1.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
ComObj.StopBits = 2
ComObj.Xon = TRUE
ComObj.Open()
ComObj.Clear()
ComObj.Write("Once again, Novell leads the way")
If(ComObj.Ready()) Then
data = ComObj.Read(1)
EndIf
ComObj.Close()
Receives a file using the xmodem protocol.
object.XmodemReceive
(FileName As String)
Boolean. Returns TRUE if successful; otherwise, FALSE.
This example receives the file test.c using the xmodem protocol.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
ComObj.StopBits = 2
ComObj.Xon = TRUE
ComObj.Open()
ComObj.Clear()
ComObj.XmodemSend("test.c")
ComObj.XmodemReceive("test.c")
Sends a file using the xmodem protocol.
object.XmodemSend
(FileName As String)
Boolean. Returns TRUE if successful; otherwise, FALSE.
This example sends the file test.c using the xmodem protocol.
Set ComObj = CreateObject("UCX:COMPort")
ComObj.Port = COM1
ComObj.BaudRate = 600
ComObj.DataBits = 7
ComObj.Parity = EVEN
ComObj.StopBits = 2
ComObj.Xon = TRUE
ComObj.Open()
ComObj.Clear()
ComObj.XmodemSend("test.c")