Interesting note, the code below as is will attempt to cast what is clearly
indicated as a string into a double. This is becuase the use of + as a
concatenation operator. The error message generated is included with the
code. Use & instead and it works.
Dim pstrSend As String = ""
'ActionCode 1 and 2 are type BYTE, Msg is a byVal string parameter
pstrSend = Chr(ActionCode1) + Chr(ActionCode2) + Msg + &HFF & vbCr
'write and flush
objSocketWriter.Write(pstrSend)
objSocketWriter.Flush()
End Function
An unhandled exception of type 'System.InvalidCastException' occurred in
microsoft.visualbasic.dll
Additional information: Cast from string "cThis is a longer test message" to
type 'Double' is not valid.
System.InvalidCastException: Cast from string "cThis is a longer test
message" to type 'Double' is not valid. ---> System.FormatException: Input
string was not in a correct format.