Port Operations in the .NET Framework with Visual Basic

You can access your computer's serial ports through the .NET Framework classes in the System.IO.Ports namespace. The most important class, SerialPort, provides a framework for synchronous and event-driven I/O, access to pin and break states, and access to serial driver properties. It can be wrapped in a Stream object, accessible through the BaseStream property. Wrapping SerialPort in a Stream object allows the serial port to be accessed by classes that use streams. The namespace includes enumerations that simplify the control of serial ports.

The simplest way to create a SerialPort object is through the OpenSerialPort method.

Note

You cannot use .NET Framework classes to directly access other types of ports, such as parallel ports, USB ports, and so on.

Enumerations

This table lists and describes the main enumerations used for accessing a serial port:

Enumeration

Description

Handshake

Specifies the control protocol used in establishing a serial port communication for a SerialPort object.

Parity

Specifies the parity bit for a SerialPort object.

SerialData

Specifies the type of character that was received on the serial port of the SerialPort object.

SerialError

Specifies errors that occur on the SerialPort object

SerialPinChange

Specifies the type of change that occurred on the SerialPort object.

StopBits

Specifies the number of stop bits used on the SerialPort object.

See Also

Reference

Ports

Other Resources

Accessing the Computer's Ports (Visual Basic)