Solved

Multiple Forms & Subs ; Objects in Modules

Posted on 1998-07-05
2
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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