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

Returning an object from a function?

Status
Not open for further replies.

davidd31415

Electrical
Joined
Nov 23, 2001
Messages
67
Location
US
I'm trying to return a user-defined class object from a different class function and am getting an "object variable or with block variable not set" error after the object initializes.

I've tried using both Property Get and Functions, both in this form:


Public Function GetDateTime() As DataPointClass
GetDateTime = New DataPointClass
GetDateTime = DateTime
End Function

Where DateTime is a DataPointClass Object. If I leave out the GetDateTime = New DataPointClass line, the same error is raised.

Any ideas how I can do this? I believe in C++ I'd need to use pointers, this is the first time I've ever tried something like this with vBA.

Thanks,

Dave
 
Hi,

maybe it's simple ... just try
Set GetDateTime = New DataPointClass
Set GetDateTime = DateTime
;o)

cheers
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top