Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Is it possible to pass a collection by reference from vb6 to vb.net?

Is it possible to pass a collection by reference from vb6 to vb.net?

Scheduled Pinned Locked Moved Visual Basic
csharpquestionannouncement
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sashaw2
    wrote on last edited by
    #1

    I have created a collection class in vb.net to pass a collection from vb.net to vb6 and everything works great. I am now trying to send a collection to a function by reference. The collection is created in vb6 but the function is in a class in vb.net. The function needs to be able to update the collection (thus byRef).

    Richard DeemingR L 2 Replies Last reply
    0
    • S sashaw2

      I have created a collection class in vb.net to pass a collection from vb.net to vb6 and everything works great. I am now trying to send a collection to a function by reference. The collection is created in vb6 but the function is in a class in vb.net. The function needs to be able to update the collection (thus byRef).

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      sashaw2 wrote:

      The function needs to be able to update the collection (thus byRef).

      Does it need to replace the collection with a new instance, or just modify items within the collection? You should only need to pass an object by reference if you're going to replace it with a different object, and want that change to be visible to the calling code.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      S 1 Reply Last reply
      0
      • S sashaw2

        I have created a collection class in vb.net to pass a collection from vb.net to vb6 and everything works great. I am now trying to send a collection to a function by reference. The collection is created in vb6 but the function is in a class in vb.net. The function needs to be able to update the collection (thus byRef).

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Only if the type is known in both environments. Enjoy[^]

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        1 Reply Last reply
        0
        • Richard DeemingR Richard Deeming

          sashaw2 wrote:

          The function needs to be able to update the collection (thus byRef).

          Does it need to replace the collection with a new instance, or just modify items within the collection? You should only need to pass an object by reference if you're going to replace it with a different object, and want that change to be visible to the calling code.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          S Offline
          S Offline
          sashaw2
          wrote on last edited by
          #4

          It does not need to replace the collection. It will need to make changes to the collection in vb.net and have those changes reflected in the vb6 collection.

          D 1 Reply Last reply
          0
          • S sashaw2

            It does not need to replace the collection. It will need to make changes to the collection in vb.net and have those changes reflected in the vb6 collection.

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            Then you don't need ByRef. Non-value types, like your collection, are always passed by reference anyway. You're not getting a copy of the collection.

            A guide to posting questions on CodeProject

            How to debug small programs
            Dave Kreskowiak

            S 1 Reply Last reply
            0
            • D Dave Kreskowiak

              Then you don't need ByRef. Non-value types, like your collection, are always passed by reference anyway. You're not getting a copy of the collection.

              A guide to posting questions on CodeProject

              How to debug small programs
              Dave Kreskowiak

              S Offline
              S Offline
              sashaw2
              wrote on last edited by
              #6

              Thanks for your help. I was able to get it working as you described.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups