About PortController
Introduction
Purchasing PortController
Redistributing PortController
License Agreement
Support
Getting Started
How to Use PortController
Using PortController with Visual Basic
Using PortController with Visual C++
Using PortController with Delphi
How to Use Events
Handling Events in Visual Basic
Handling Events in Visual C++
Handling Events in Delphi
PortController Sample Projects
Reading and Writing Binary Data
Handling PortController Errors
Reference
Properties
BaudRate Property
Break Property
BytesUsedRQ Property
BytesUsedTQ Property
Cd Property
Cts Property
DataBits Property
Dsr Property
Dtr Property
DtrDsr Property
EnableReadOnEventChar Property
EventChar Property
Parity Property
PortHandle Property
PortName Property
Ring Property
Rts Property
RtsCts Property
StopBits Property
XonXoff Property
Methods
ClearRQ Method
ClearTQ Method
Close Method
GetErrorStatus Method
Open Method
Read Method
ReadBinary Method
Write Method
WriteBinary Method
SendXoff Method
SendXon Method
Events
BreakSignal Event
CdToggle Event
CtsToggle Event
DataReceived Event
DsrToggle Event
Error Event
EvtCharReceived Event
Ring Event
TQEmpty Event

DataBits Property

Sets and returns the data bits communications parameter.

Syntax

Visual Basic

object.DataBits [ = value ]

Visual C++

object.GetDataBits()

object.SetDataBits(value)

Delphi

object.DataBits [ := value ]

Part Description
object An object expression that evaluates to a PortController object.
value An integer representing the data bits in each frame.

Example

Visual Basic

'Set data bits
myPortController.DataBits = 8

'Get data bits
Dim dataBits as Integer
dataBits = myPortController.DataBits

Visual C++

// Set data bits
m_myPortController.SetDataBits(8);

// Get data bits
int dataBits = m_myPortController.GetDataBits();

Delphi

// Set data bits
myPortController.DataBits := 8;

// Get data bits
var dataBits: Integer;    // declare variable in the proper place
dataBits := myPortController.DataBits;

Remarks

Valid data bits values are as follows:

8 (Default)
7
6
5

Default

8

Returns

An integer representing the data bits parameter.

Errors

  • Attempting to set DataBits to an invalid value will cause the PortController to throw an "Invalid argument" exception.

  • Attempting to set DataBits to 6, 7, or 8 when StopBits is 1.5 is illegal and will cause the PortController to throw a "Invalid stop bits / data bits combination" exception if the port is open. If the port is closed, no exception will be thrown.

  • Attempting to set DataBits to 5 when StopBits is 2 is illegal and will cause the PortController to throw an "Invalid stop bits / data bits combination" exception if the port is open. If the port is closed, no exception will be thrown.

See Also

Parity, BaudRate, StopBits, Open()