OutputMode
Sets or Retrieves the property indicating the OutputMode
Available at design time and runtime.
Only available with Comm32 (Not available with MSComm)
 |
| |
Syntax |
object.OutputMode = value |
| |
|
|
| |
object |
Name of the communications control. |
| |
value |
A numerical expression being one of the following values.
0 = comOutputModeText (Default)
1 = comOutputModeBinary |
| |
|
|
| |
Examples |
object.OutputMode = 0 |
'// Set the value (Text mode) |
| |
|
|
|
| |
|
if object.OutputMode = 1 then
MsgBox("Mode is Binary ")
Else
MsgBox("Mode is Text ")
End If |
'// retrieve the current setting |
| |
|
|
|
|
 |
Remarks:
Difference in functionality between MSComm and Comm32
Microsoft's MSComm32 component has an InputMode property which defines how bytes are RECEIVED. (As text or as an array of Bytes) But MSComm32 does not have an OutputMode property. MSComm's Output property is able to autodetect the datatype and process it accordingly so does not require any specific mode setting. However, some developers report that MSComm sometimes incorrectly detects the datatype causing data errors.
To avoid such discrepancies we have introduced a new property. OutputMode
comOutputModeText (Default) The Output property will handle data as a String. Individual elements of the string may contain any ascii/byte value including control codes etc.
comOutputModeBinary The Output property will handle data as an Array of Bytes.
For example:-
Dim i as Byte
'// Now we'll create an array of bytes and populate it with some byte values.
Dim myByteArray(1 to 20) as Byte
For i = 1 to 20
myByteArray( i ) = i
Next i
Comm1.OutputMode = 1
Comm1.Output = myByteArray
'// This sample would transmit the numerical byte values 1 to 20 |