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()
|