Popup Menu

HI ,

I have one basic question , kindly help me out from this.
I have created the serial testing terminal. In this I have created the Popup menu for select Baud rate.

my code is

Popup menu - Open

Dim baudrate() As String = Array(“300”, “600”, “1200”, “1800”, “2400”, “3600”, “4800”, “7200”, “9600”, “14400”, “19200” , “28800” , “38400” , “57600” , “115200” , “230400”)

For Each br As String In baudrate

Me.AddRow(br.ToText)

Next

==========================================
Popup menu - Change

If Me.ListIndex = -1 Then Return

Serial1.Baud() = Serial1.Baud(Me.ListIndex)

While run the same i have received the error as “This is not an array but you are using it as one”.

Serial1.Baud = Me.ListIndex

Serial.Baud is a property not an array. You need to set it to the listindex.

This code makes no sense.

If you want to assign the Baud rate based on what has been selected then you would use the Serial.Baud property. It is not an array and it takes an Integer. The PopupMenu values are Strings which you can get using its List property (it is an array), but you’ll need to convert it to a number. This can all be done like this:

Dim baudRate As String = Me.List(Me.ListIndex) // Get selected item in PopupMenu Dim baudRateValue As Integer = Val(baudRate) // Convert to a number Serial1.Baud = baudRateValue // Set the Baud rate for the Serial control

Or in a single line of code:

Serial1.Baud = Val(Me.List(Me.ListIndex))

According to the documentation http://documentation.xojo.com/index.php/Serial.Baud use of the listindex is correct to get the value of the class constant.

Well, I’ll be. I should read the documentation (and not post code late at night).

Do what Wayne has said.