Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Multiple Forms & Subs ; Objects in Modules

Posted on 1998-07-05
2
Medium Priority
?
146 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 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

609 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