|
PortController.NET
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:
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
|