SerialConnection in Xojo 2019r21

Hi I just installed Xojo 2019r21 and now I can’t figure out how to connect to a comport with the new SerialConnection.

I want to connect to COM1 but I am not sure where to set it.

I have tried this. But I just get an error that says “You must use the value returned by this function”

MessageBox(“The serial connection is open.”)
Catch error As IOException
MessageBox(“The serial connection could not be opened.”)
End Catch

I do not use API2 so can’t help much, BUT this is not an API issue as such.
I suspect ‘SerialConnection1.Connect’ returns a value so do this:-

Call SerialConnection1.Connect

that allows you to ignore the return value


SerialConnection.Connect doesn’t return a value according to the documentation.

Using the code I created for another app, on a 2018 version:

[code]SerialConnection1.Device = SerialDevice.WithName(“COM7”)

IF SerialConnection1.Connect Then
’ Code here
dt = Chr(&h7A) + Chr(&h31) + Chr(&h00) + Chr(&h55)
Window1.ParkAnt.BackColor = white
MsgBox(“The selected serial port could not be opened.”)
End If[/code]

This code seems to support that because it doesn’t work, I get the “This method doesn’t return a value” error on line "IF SerialConnection.Connect . . . .

So, how do you determine if the port is connected?


you can open a specific port with the first line above:
SerialConnection1.Device = SerialDevice.WithName(“COM7”)
rather than having to use the System scan list. Sometimes you just need to open a specific port.

it’s in the docs.

  MessageBox("The serial connection is open.")
Catch error As IOException
  MessageBox("The serial connection could not be opened.")
End Try

I am in a hurry but remembered a guest Blog Post on

Hope it helps a bit.