Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7650549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:16:48+00:00 2026-05-31T11:16:48+00:00

I want to pass my set of objects and variables to VBA function, make

  • 0

I want to pass my set of objects and variables to VBA function, make some changes to it and pass it back as a result. So I create a sample Class1:

Public pInfo As String

and sample function:

Public Function populate(someVar As Class1) As Class1

    populate.pInfo = someVar.pInfo & " 1 "

End Function

and tryed to pass it to my function populate:

Sub test()
Dim v, w As Class1
Set v = New Class1
v.pInfo = "303"
Set w = populate(v) ' ERROR here

End Sub

results in compile error : byRef argument type mismatch.

UPDATE. Thanks to your help it compiles now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:16:49+00:00Added an answer on May 31, 2026 at 11:16 am

    Its a type error

    Dim v, w As Class1
    

    Unintuitively here only w is of type Class1, v is a variant.
    To make them both Class1 you must:

    Dim v As Class1, w As Class1
    

    Here:

    Public Function populate(someVar As Class1) As Class1
        populate.pInfo = someVar.pInfo & " 1 "
    End Function
    

    populate is not an instance of Class1, you need to create it:

    Public Function populate(someVar As Class1) As Class1
        set populate = new Class1
        populate.pInfo = someVar.pInfo & " 1 "
    End Function
    

    (Rather than using a function you may prefer a v.copyTo(w))

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pass in the tType of a class to a function, and
I want to pass some parameters to my MVC UserControl like ShowTitle(bool) and the
I want to pass a few variables to another page. Currently I'm using response.redirect
i want to pass large variables to a PHP script on another server with
I want two objects to share a single string object. How do I pass
I want pass a value to ssis package, but i have an error back
I want to make a constructor function that creates a documentElement object. As an
I want to create a 'File' object that returns 'Line' objects when the ReadLine()
In php 5.3, when you create an anonymous function, can you set the default
I want to pass an integer value to a form in .Net so that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.