Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • 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
Nov 23, 2001
67
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
 
Replies continue below

Recommended for you

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