Solved

Re-use some class modules

Posted on 2002-07-16
3
137 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 143

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

790 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