Serial Comm Port

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
Umbridge
Posts: 5
Joined: Tuesday 28th November 2023 5:43pm

Serial Comm Port

Post 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.
Attachments
1.png
1.png (54.21 KiB) Viewed 10925 times
User avatar
BruceSteers
Posts: 1579
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Serial Comm Port

Post 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.
If at first you don't succeed , try doing something differently.
BruceS
Umbridge
Posts: 5
Joined: Tuesday 28th November 2023 5:43pm

Re: Serial Comm Port

Post by Umbridge »

It seems that the problem is not in the syntax, but in the system) try this simple example for yourself)
Attachments
Screenshot_20231208_102224.png
Screenshot_20231208_102224.png (47.13 KiB) Viewed 10443 times
Post Reply