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. Passing data between forms

Passing data between forms

Scheduled Pinned Locked Moved Visual Basic
question
7 Posts 2 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.
  • A Offline
    A Offline
    Andrew Bromfield
    wrote on last edited by
    #1

    Hello, I need some sound advice, here is the scenario: I have a mdiChild form that contains a button that launches a owned (owned by the mdiChild) form. My questions is: What is the most effective way to pass data from the owned form to the appropriate member variables declared on the mdiChild form (owner)? Thanks in advance, Andrew

    A 1 Reply Last reply
    0
    • A Andrew Bromfield

      Hello, I need some sound advice, here is the scenario: I have a mdiChild form that contains a button that launches a owned (owned by the mdiChild) form. My questions is: What is the most effective way to pass data from the owned form to the appropriate member variables declared on the mdiChild form (owner)? Thanks in advance, Andrew

      A Offline
      A Offline
      Andrew Bromfield
      wrote on last edited by
      #2

      It's alright I figured it out. I created a custom constructor for the owned form that accepts an instance of the mdiChild form. Example: (Owned Form Declaration) Public Sub New(ByRef mdiChildInstance As frmMdiChild) MyBase.New() _mdiChildInstance = mdiChildInstance End Sub (OwnedForm Instantiation - code is located on the MdiChild Form) Public OwnedForm As New frmOwnedForm(Me) I also created public properties for all of the member variables on mdiChild. Does anyone see any red flags with the code above? Thanks, Andrew

      A 1 Reply Last reply
      0
      • A Andrew Bromfield

        It's alright I figured it out. I created a custom constructor for the owned form that accepts an instance of the mdiChild form. Example: (Owned Form Declaration) Public Sub New(ByRef mdiChildInstance As frmMdiChild) MyBase.New() _mdiChildInstance = mdiChildInstance End Sub (OwnedForm Instantiation - code is located on the MdiChild Form) Public OwnedForm As New frmOwnedForm(Me) I also created public properties for all of the member variables on mdiChild. Does anyone see any red flags with the code above? Thanks, Andrew

        A Offline
        A Offline
        apferreira
        wrote on last edited by
        #3

        :wtf::wtf::wtf::wtf::wtf:The memory footprint of this kind of coding is a serious problem.

        A 2 Replies Last reply
        0
        • A apferreira

          :wtf::wtf::wtf::wtf::wtf:The memory footprint of this kind of coding is a serious problem.

          A Offline
          A Offline
          Andrew Bromfield
          wrote on last edited by
          #4

          So what is your suggestion?

          1 Reply Last reply
          0
          • A apferreira

            :wtf::wtf::wtf::wtf::wtf:The memory footprint of this kind of coding is a serious problem.

            A Offline
            A Offline
            Andrew Bromfield
            wrote on last edited by
            #5

            Why is it a serious problem? A form is just a class, and it's common practice to create and pass values to custom constructors, correct? Andrew

            A 1 Reply Last reply
            0
            • A Andrew Bromfield

              Why is it a serious problem? A form is just a class, and it's common practice to create and pass values to custom constructors, correct? Andrew

              A Offline
              A Offline
              apferreira
              wrote on last edited by
              #6

              A form is a class, but once instanciate it is an object that ocupies memory space. The bigger the object, the bigger the cost of passing it through constructors. Yes, if you pass it by reference instead you eliminate some of that cost because the CLR does not create a copy of the object. But it is better practice to pass smaller objects through constructors.

              A 1 Reply Last reply
              0
              • A apferreira

                A form is a class, but once instanciate it is an object that ocupies memory space. The bigger the object, the bigger the cost of passing it through constructors. Yes, if you pass it by reference instead you eliminate some of that cost because the CLR does not create a copy of the object. But it is better practice to pass smaller objects through constructors.

                A Offline
                A Offline
                Andrew Bromfield
                wrote on last edited by
                #7

                Thank you for the explanation. What you're saying makes absolute sense. Your help is much appreciated. Thanks again, Andrew P.S What is a better way to pass data between mdiChild forms?

                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