Share via


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. To access your computer's network, see Classes Used in .NET Framework Network Operations (Visual Basic).

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.

Tasks

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

To

See

Show available serial ports

How to: Show Available Serial Ports in Visual Basic

Dial a modem attached to the serial port of a computer

How to: Dial Modems Attached to Serial Ports in Visual Basic

Send a string to a computer's serial port

How to: Send Strings to Serial Ports in Visual Basic

Receive a string from a computer's serial port

How to: Receive Strings From Serial Ports in Visual Basic

See Also

Reference

Ports

Other Resources

Accessing the Computer's Ports (Visual Basic)

Going Further with Visual Basic