how to pass decimal values over serialport control?
Start by convering whatever values that you want to pass into a byte array (System.Byte()
), and then use the SerialPort.Write(Byte(), Int32, Int32)
overload to write them to the serial port.
That overload allows you to specify the array of bytes that will be passed, the offset of the array at which to begin, and the number of bytes out of the array that should be passed.
Obviously you've looked already, so you know that you are not going to find an overload for the SerialPort.Write
method that writes integer or decimal values directly.
Use SerialPort Class.
精彩评论