
result = SerialPort.Open("COM1:", 9600, 8, SP_NOPARITY, SP_ONESTOPBIT, SP_HANDSHAKE_OFF)
IF result <> 0
{
Form.MessageBox("Error", "Could not open port", 0)
EXIT
}
WHILE result == 0
{
str = SerialPort.ReadString("COM1:", 10000)
IF str <> NULL
{
edit_control1 = edit_control1 & str
IF str == ""
{
result = -2
}
}
ELSE
{
result = -1
}
}
result = SerialPort.GetLastError("COM1:")
str = "Error when reading message " & result
Form.MessageBox("Exiting", str, 0)
SerialPort.Close("COM1:")
Note:
cboxDateTime – a Form control, check box used as a flag in this instance to check whether to display or hide the datetime picker.
dtOrderDate – a Form control, datetime picker.
A disabled datetime picker will appear shaded out on the form.
This code segment opens COM1 first and reads the string from this port. It will display any errors while opening, reading and closing COM1.