Page 1 of 1

Serial Comm Port

Posted: Monday 4th December 2023 12:04pm
by Umbridge
Good afternoon) I'm trying to figure out the serial port. I would like to use only graphical ActiveX settings as in VB6. The task is simply to send the contents of textbox1 to the serial port when the button is pressed. Tell me the minimum possible program for this. The port has already been specified. It remains to understand the sequence and syntax. As I understand it, you do not need to open the port as in VB6.

Re: Serial Comm Port

Posted: Monday 4th December 2023 12:44pm
by BruceSteers
I have never used SerialPort control but it looks like it inherits Stream.class

I assume you have read all the help on the wiki...
SerialPort @ https://gambaswiki.org/wiki/comp/gb.net/serialport
Stream @ https://gambaswiki.org/wiki/comp/gb/stream

to write to a stream it is done something like this..
(I think the stream MUST be Opened before writing but i could be wrong.


Dim sMyText As String = "This is some text"

SerialPort1.Open  ' open the port for communication

Write #SerialPort1, sMyText    ' write the text to the stream

Print #SerialPort1, "Using Print will add linefeed to end of string"

SerialPort1.Close  ' close the port after use.



But like i say i only assume this is how serialport works as i do not have anything to test the code on.

Re: Serial Comm Port

Posted: Friday 8th December 2023 7:29am
by Umbridge
It seems that the problem is not in the syntax, but in the system) try this simple example for yourself)