Solved

Re-use some class modules

Posted on 2002-07-16
3
136 Views
Last Modified: 2010-05-02
I have two different VB6 projects.
I want to re-use one class module from project A, so I opened the project B and selected "Add Class Module" to add the moda.cls file. But when I tried to compile project B, the following error occur:

Set  moda  = New moda
        ^          ^
"Compile error: Variable not defined"

Why? How can I fix this error?
Thank You.

raymng
0
Comment
Question by:Raymond
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 7157222
Do you have somewhere the moda variable declared?

For problem like this, you should have the following line on top of each module:
OPTION EXPLICIT
this requests that you have every variable declare before you can use it in code.

CHeers
0
 

Author Comment

by:Raymond
ID: 7157283
Oh, thanx!
I overlooked this.
0
 
LVL 10

Expert Comment

by:GoodJun
ID: 7157284
Don't use the same name with variable and class

dim objmoda as moda
Set  objmoda  = New moda
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

809 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