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)


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").


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.

By: Guest KenPosted on: Jun 24 2020 at 07:36:33 AM
I'm trying to test this with my code using the free sample OCX.

I have the following declaration in a Class Module:

Dim WithEvents m_comm As SCommLib.SComm

Then in the Class Initialize method I have:

Set m_comm = CreateObject("SCommLib.SComm")

When I run that I get "Run_time error '13' Type mismatch.

Is this something that only works in the paid-for version?

By: Guest KenPosted on: Jun 24 2020 at 08:40:46 AM
Never mind. I messed up the reference in the project. It's working fine now.

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