FrymasterVB/DWPORT.CLS.md

1.2 KiB

DWPORT.CLS Documentation

Overview

DWPORT.CLS is a class file that handles port-related operations and configurations.

Class Description

The DWPORT class provides functionality for managing and interacting with hardware ports.

Usage

Dim port As New DWPORT

Methods

Open

Opens a connection to the specified port.

port.Open(portNumber As Integer) As Boolean

Close

Closes the current port connection.

port.Close()

Read

Reads data from the open port.

port.Read() As String

Write

Writes data to the open port.

port.Write(data As String)

Properties

IsOpen

Returns whether the port is currently open.

port.IsOpen As Boolean

PortNumber

Gets or sets the current port number.

port.PortNumber As Integer

BaudRate

Gets or sets the port baud rate.

port.BaudRate As Integer

Error Handling

The class includes built-in error handling for common port operations:

  • Port already in use
  • Invalid port number
  • Connection timeout
  • Read/Write errors

Dependencies

  • System.IO.Ports
  • Microsoft.VisualBasic

Example Usage

Dim port As New DWPORT port.BaudRate = 9600 If port.Open(1) Then port.Write("Test Data") Dim response As String = port.Read() port.Close() End If