Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Classes and Defined Types ...Errors!! Pls help!

Status
Not open for further replies.

Forri

Programmer
Oct 29, 2003
479
MT
Hi

I have a Project group containing three projects! A Standard Exe and ActiveX Dll And another having User Controls!

For the Standard EXE to work with the ActiveX Dll i refernce it through the References button! Then i use

Dim myObject as class1

But when i run (F5) the project i recieve an error stating that the class1 variable was not defined!!??

"User-defined variable not defined" .. or something like that!

On the OCX the same error is given when i try to access an ocx Enum Variable:

myControl.Type = MBUTTON ...this does not work but this

myControl.Type = 0 ...where 0 is the equvenlent of MBUTTON works!!!

Do you have some solutions!!?

Thanks

 
what code do you want! its quite alot!
 
Should it be

Dim myObject as new class1 ?? With the new keyword?

Also you may need to fully qualify the dll class, dllName.class1 although probably not if it is compiling. Probably just missing new keyword ..

Hope this helps!

Transcend
[gorgeous]
 
Yes you're right but i create the instance of the class using the 'new' word on the load event!

You're also right when you said that i should qualify all the dll class using the dll.class1! but usually it works with the 'class1' part only or i'm wrong?!!

Is it ok to right dll.class1 or?

Thanks for your help!
 
Making a project group is not what will make class1 visible to other projects.
Select your standard exe project, then use menu Project, References, and check dll.vbp project, or add reference to dll.
 
Yes i've done that! what i'm trying to explain is that after referenceing it and all i still have to write

dim myObject as new dll.class1

where i usually only write

Dim myObject as new class1

After using the latter one an error is givin! but if i use the first one it works!

Is it ok if i write
dim myObject as new dll.class1

or?

Thanks again
 
If "as dll.class1" is required, you have class1 defined in two (or more) places. Use Object browser (F2) to find second definition of class1, or do a search.
 
yes i defined it in more than one form does that mean that i'm doing something wrong!! i'm using the Private keyword!

 
By "define class1" I DIDN'T mean you declared variable of the type class1, like "private x as class1", that should work.

To clarify:
Do you have variable *named* class1, like:
Private class1 as anything
or control, module (other then the one in your dll) or form named "class1"
Use Object Browser.
 
Sorry misunderstood!! No it shouldn't be! Its quite puzzling but i'll check it out! thanks again
 
In the DLL, is class one defined as a public class? Check it's property window...

mmilan
 
Should be...good point! i'll check out later!! Thanks
 
Hi,

In your standard exe project you mentioned that you had 3 projects in it (a DLL, an OCX, and the standard EXE). You mentioned that you had a reference to the DLL as well. If this is correct try:

1) Remove the DLL from your project group.
2) Remove the refererence to the DLL.
3) Save the EXE project group.
4) Recompile and make the DLL project.
5) Don't add the refererence to the DLL back but use CreateObject() to make objects from your DLL like:

set MyDLLObj = CreateObject(MyDll.Class1)

Note: You should use a better class name than 'class1'.

Have a good one!
BK
 
thanks BK .. iused class1 just as an example!

Its not a whole project but a group with 3 projects!

I cannot compile the dll cause its still not ready!

Thanks for the suggestion will keep it in mind for later use!

Thanks
N
 
[/b]Forri[/b]

I had a similar problem (long time ago!)
I think this solved it for me!

I had two references to the DLL object, 1 caused by compiling / making the DLL and 1 from the project group.

To check this, remove the DLL from the project group. Check you references for the exe project, which should show &quot;missing:<your dllname>&quot; or similar. If not, it appears that the DLL is already registered and that you are using that type libary fo your reference, which doesn't include the methods / class etc.
If you still have a reference (not showing missing) in the IDE, you need to unregister the DLL (regsvr32 <dllpath and name> /u)
Add the DLL to the project group again and recheck the reference!

I would also check the instancing property of class1

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Hi,

Forri:

Yes, as I previously mentioned the project group has 3 projects. The problem is due to the fact you have a reference to the DLL and it is also in your project group!!! Remove either one of them.

BTW if your DLL project hasn't been compiled and made then DEFINITELY remove ir from the references.

Have a good one!
BK
 
>Thanks all

forri

Does this mean your problem is resolved? If so, I would be gratefull if you tell us what actually solved the problem!

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
i'm still fiddling..c as the problem only crops up on my laptop on my computer nothing happens ! so i still have to check some things! i will be back in a few minutes! i just wanted to thank u for your interest!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top