Solved

Multiple Forms & Subs ; Objects in Modules

Posted on 1998-07-05
2
136 Views
Last Modified: 2010-05-03
I am writing some code that talks to some equipment through the COM Port. I use the MSCOMM control and one custom SUB to decifer the output and input from the equipment. I want to talk to this SUB from several Forms, so I tried putting it into a Module so all the forms could see it. But when I run it I get an "Object required" Error (Referring to the MSCOMM Object). But as far as I can tell there is no way to attach or insert an object into a module. I am pretty new at this Language, so should I be using a class module or something. Basically, I want several forms to use the same sub to talk to the COM port. How would I go about doing this.
0
Comment
Question by:willmrk
2 Comments
 
LVL 4

Expert Comment

by:tomook
ID: 1464987
Please show us the code in error. I think I know what the problem is, but I want to be sure I am not leading you down the wrong path.
0
 
LVL 6

Accepted Solution

by:
alamo earned 100 total points
ID: 1464988
You are correct, you can't place an object into a module. There are two ways to do this:

1.Leave the sub in the module and access teh control by qualifying the control name with the form name, e.g

Form1.MSComm1.CommPort = 1

2. Place the sub in the form as Public and call it from outside the form by again qualifying the sub name with the form name. For example

Form1.DecodePacket(packet$)

Hope this helps!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now