Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

assign ComPort to variable


tjwilli_58 Sep 30, 2016 08:19 PM

Is there a way to assign a ComPort(COM1, COM2, etc) to a variable?  I have a program I'd like to use on multiple dataloggers, but the device I'm connecting to may not be on the same ComPort. Instead of doing a search/replace changing Com1 to Com2 whereever it's needed, I'd like to only change it at the top of the program.

I tried something like:

Dim wxtCom = Com1

but I got a compile error.on SerialOpen(wxtCom,....)

Am I asking too much?


JDavis Sep 30, 2016 08:26 PM

You can use a constant for the comport number in SerialOpen.

Const wxtCom = Com1

All the other serial instructions can use either a constant or a variable.


tjwilli_58 Sep 30, 2016 08:27 PM

Dug around the help a little more and discovered Const.

Const wxtCom=Com1

works just fine. If there's a better way, please reply.


tjwilli_58 Sep 30, 2016 08:28 PM

Thanks. I should have just waited one more minute!


pokeeffe Sep 30, 2016 08:38 PM

You might find `ConstTable` useful as well. 

Log in or register to post/reply in the forum.