×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Returning an object from a function?

Returning an object from a function?

Returning an object from a function?

(OP)
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

RE: Returning an object from a function?

Hi,

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

cheers
Michael

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources