About PortController
Introduction
Purchasing PortController
Redistributing PortController
License Agreement
Support
Getting Started
How to Use PortController
PortController Sample Projects
Handling PortController Errors
Reference
Properties
AvailableSystemPorts
BaudRate Property
Break Property
BytesUsedRQ Property
BytesUsedTQ Property
Cd Property
Cts Property
DataBits Property
Dsr Property
Dtr Property
DtrDsr Property
EnableReadOnEventChar Property
EventChar Property
ForceBeginInvokeEventFiring Property
IsOpen Property
IsFileTransferInProgress Property
Parity Property
PortHandle Property
PortName Property
ReceiveBufferSize Property
Ring Property
Rts Property
RtsCts Property
StopBits Property
SystemPorts Property
TraceOutput Property
TransmitBufferSize
XoffByte Property
XonByte Property
XonXoff Property
Methods
CancelFileTransfer Method
ClearRQ Method
ClearTQ Method
Close Method
GetErrorStatus Method
Open Method
Read Method
ReadBinary Method
ReceiveFileXModem Method
ReceiveFileXModemCRC Method
ReceiveFileYModem Method
ReceiveFileZModem Method
SendFileXModem Method
SendFileXModem1k Method
SendFileYModem Method
SendFileZModem Method
SimulateReceivedXoff Method
SimulateReceivedXon Method
Write Method
WriteBinary Method
Events
OnBreakSignal Event
OnCdToggle Event
OnCtsToggle Event
OnDataReceived Event
OnDsrToggle Event
OnError Event
OnEventCharReceived Event
OnFileTransferComplete Event
OnFileTransferStatusUpdate Event
OnRing Event
OnTQEmpty Event

DataBits Property

Sets and returns the data bits communications parameter.

Syntax

[Visual Basic]
object.DataBits [ = value ]

[C#]
object.DataBits [ = value ]

[C++]
object->DataBits [ = value ]

Parameters

object

An object expression that evaluates to a PortController object.

value

An Int16 representing the data bits in each frame.

Return Value

An Int16 representing the data bits in each frame.

Remarks

Valid data bits values are as follows:

  • 8 (Default)
  • 7
  • 6
  • 5

Default

8

Errors

  • Attempting to set DataBits to an invalid value will cause 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 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 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.

Example

[Visual Basic]
'Set data bits
myPortController.DataBits = 8

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


[C#]
// Set data bits
myPortController.DataBits = 8;

// Get data bits
Int16 dataBits = myPortController.DataBits;

[C++]
// Set data bits
myPortController->DataBits = 8;

// Get data bits
Int16 dataBits = myPortController->DataBits;

See Also

Parity property | BaudRate property | StopBits property | Open method