Comm32 Logo
Home Button  Buy Button 

Topic:   Adding SComm32 at runtime

By: GuestPosted on: Feb 20 2020 at 02:22:45 PM
Please tell me the Scomm32 equivalent of this VB6 code

Public WithEvents EchoPort As MSComm
Set EchoPort = Controls.Add("mscommlib.mscomm.1", "EchoPort", frmMain)

Tnx.


By: GuestPosted on: Feb 25 2020 at 10:02:19 AM
In most case SComm32 has the same syntax as MSComm32 but without the 'M'. So

Set MSComm1 = CreateObject("MSCommLib.MSComm").

becomes

Set SComm1 = CreateObject("SCommLib.SComm").

One thing I will add is that when you come to us the .Input method it will fail. It seems that the word 'Input' is a reserved word in many programming languages. When using the scomm32 control on a form it's not a problem but, for some reason, when creating the scomm32 object at runtime the Input method doesn't work. So use the alternate call .Read instead so SComm1.Read instead of Scomm1.Input Apart from that everything else is the same as MSComm32

By: Guest MikePosted on: Feb 25 2020 at 10:06:49 AM
No real need to .Add the control to the form. Just declare it in code the same way that MSComm32 can be declared in code without programmtically .Add ing it to the form.

'''At the very top of your code outside of any function
Private withevents SComm1 as SComm32.SComm

'''Then inside the load event
Set SComm1 = CreateObject("Scomm32.SComm")

Then notice what the previous post mentioned about the .Input method. Or maybe if you do programmatically add it to the form then maybe the .Input method will work - but it's no big deal to change the calls to .Input to .read

By: GuestPosted on: Feb 26 2020 at 01:25:51 PM
Many thanks for the tips. Bob.

Reply - add a comment to this topic.

You may enter letters, numbers and standard punctuation only. HTML and other scripts/tags will be rejected.

Topic:- Adding SComm32 at runtime


Enter the numbers.

Your name here is optional