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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Instance from Class Module

Status
Not open for further replies.

caseye

IS-IT--Management
Feb 7, 2002
52
0
0
US
I am trying to create an objet from a class module in the same project And I dont know If have the syntax right because after i create it i can not access the public properties I know the class module works because i can create it at declaration but i dont want to do that here is what i am using.
Thanx in ad vanced

Set TempObj = CreateObject(Contact)

The reason for this is TempObj is used for different classes at different places in the code. Instead of creating individual variables for each class I have a temp container because when the objects are created they are immediately added to a collection.
 
Dim TempObj As Object
Set TempObj = new Contact
Set TempObj = Nothing

Set TempObj = New Appointment
Set TempObj = Nothing

If you really want to do it that way.....
 
If you have a better way i am all ears
 
Also when I try it the way you specified i get a type mismatch error.
 
I guess I didn't see the word "collection" the first time. Is that correct...is the Dim TempObj As Object in a collection class, or being added to a normal collection?
Are you adding two different objects to the same collection?
 
It is adding the same objects to the collection how ever there are several different object collections each containing a collection of a particular object. thats the intent anyway. that is the reason for the tempObj. that way i dont have to create a temp variable for each type of

I am New to collections and have not worked much with OOP in visual basic. So I might be going about this project the wrong way.
 
You didn't say if your project is an exe or activeX. I don't believe you can use createobject to call a class within an exe project. CreateObject creates and returns a reference to an ActiveX object.

Also, "Set TempObj = CreateObject(Contact)" should read
Set TempObj = CreateObject("projectName.Contact") if it is an aciveX dll or activeX exe project. Note use of quotes

I think cclint advice is better if your project is an exe.

 
You didn't say if your project is an exe or activeX. I don't believe you can use createobject to call a class within an exe project. CreateObject creates and returns a reference to an ActiveX object.

Also, "Set TempObj = CreateObject(Contact)" should read
Set TempObj = CreateObject("projectName.Contact") if it is an aciveX dll or activeX exe project. Note use of quotes

I think cclint advice is better if your project is an exe.

 
how do i create an bject in an exe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top