vb express SerialPort control error

When I select the value "None" for the StopBits property on an instance of this control, I get a message <Property Value is not valid> with the following detail:

"Enum value was out of legal range.
Parameter name: StopBits"

This happens when I choose the value from the drop-down list, so it has to be a bug. Does anyone know how I can specify no stop bits




Answer this question

vb express SerialPort control error

  • JC Carmo

    Me.SerialPort1.StopBits = IO.Ports.StopBits.None



  • Sanomo

    It is not that crazy to allow no stopbit. SerialPort is general useable, and if you e.g. wants to use it with a communication that uses NRZI (Not Return to Zero Invert), no stop bit is required. As far as I remember, low speed USB uses NRZI.

    A standard UART uses NRZ coding where it is necessary with both a start bit and a stop bit, but if the communication is coded with NRZI, where the line state is inverted each time a "0" is transmitted, no stop bit is required. So when SerialPort uses the underlying SerialStream object it must tell how many stop bits are required and it is a little foolish to specify 1 if none is required - even though the driver can of course just ignore this field in case of NRZI coding.


  • Fraas

    This, I believe, is a bug. There's no such thing as no stop bits (there was a discussion about this, not too long ago). You can only specify one, one and a half or two stop bits: these are the only valid values.



  • Marie C

    When I try your suggestion, the app won't run. Reports error Enum Value out of range.

  • kasl33

    I didn't knew that the set function does not allow no stopbits. You are right that such inconsistency is not very clever. I just thought that maybe Microsoft had done some thinking when they allowed no stopbits, but it is obviously not the case!


  • Muhammad Abrar

    I understand all that, but the problem is that Microsoft has supplied conflicting code for the Stopbits part of the Serialport class. In the get portion it returns 4 values but the set portion will only allow 3 of those to be used. So how can you tell the underlying SerialStream object to use none stopbits when the SerialPort object prevents you from doing this. I read somewhere else the reason for this problem is in the underlying unmanaged Comport API, which only has 3 stopbits defined.

  • lym51

    Just don't use the 'none'.

  • jayk

    The bug is in .NET because I get the same error using C#.

    I fill a combobox using serialPort.GetNames and it returns 4 values None, One, OnePointFive and Two.

    Also when in debugging mode and you check the values available for StopBits it also shows 4 values.

    Will MicroSoft be issuing an update/patch for this error in .NET 2.0


  • boorad

    I came to the same conclusion.

    But the point I wished to make is that for someone new to .NET and in particular serial port communications on .NET it can lead to some frustration and head scratching to work out what is wrong when Microsoft supplies sample code that contains the following Enum.GetNames(typeof(StopBits)) and this returns 4 values including None.

    I searched Support Knowledge Base without finding any help. It was only when I came across this thread that the penny dropped.

  • vb express SerialPort control error