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. Structure passing problem

Structure passing problem

Scheduled Pinned Locked Moved Visual Basic
helpdatabasevisual-studio
6 Posts 3 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.
  • B Offline
    B Offline
    Bret Stern
    wrote on last edited by
    #1

    I'm moving from VB6 to VS 2008. And need help with a data structure problem. In a Public code module in my VS 2008 project, I defined a structure: Public structure db_connection dim connection_string as string End structure Then defined a variable as the structure type: Public db_con as db_connection When I pass the db_con variable to a sub: sub db_create_cs(dbc as db_connection) dbc.connection_string = "some values" end sub I expected the db_con.connection_string value to equal "some values" after the call. Regards.

    D D 2 Replies Last reply
    0
    • B Bret Stern

      I'm moving from VB6 to VS 2008. And need help with a data structure problem. In a Public code module in my VS 2008 project, I defined a structure: Public structure db_connection dim connection_string as string End structure Then defined a variable as the structure type: Public db_con as db_connection When I pass the db_con variable to a sub: sub db_create_cs(dbc as db_connection) dbc.connection_string = "some values" end sub I expected the db_con.connection_string value to equal "some values" after the call. Regards.

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      Check to see if in your declaration,

      sub db_create_cs(dbc as db_connection)

      the parameter is ByRef as opposed to ByVal. Also, you might want to re-structure your program to define db_create_cs as a function rather than a sub. (my 2 cents) Hope this helps. :thumbsup:

      B 1 Reply Last reply
      0
      • B Bret Stern

        I'm moving from VB6 to VS 2008. And need help with a data structure problem. In a Public code module in my VS 2008 project, I defined a structure: Public structure db_connection dim connection_string as string End structure Then defined a variable as the structure type: Public db_con as db_connection When I pass the db_con variable to a sub: sub db_create_cs(dbc as db_connection) dbc.connection_string = "some values" end sub I expected the db_con.connection_string value to equal "some values" after the call. Regards.

        D Offline
        D Offline
        Dave Doknjas
        wrote on last edited by
        #3

        If you don't specify "ByRef" or "ByVal", then the parameter is "ByVal" by default. You want:

        Sub db_create_cs(ByRef dbc As db_connection)

        David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

        B 1 Reply Last reply
        0
        • D David Mujica

          Check to see if in your declaration,

          sub db_create_cs(dbc as db_connection)

          the parameter is ByRef as opposed to ByVal. Also, you might want to re-structure your program to define db_create_cs as a function rather than a sub. (my 2 cents) Hope this helps. :thumbsup:

          B Offline
          B Offline
          Bret Stern
          wrote on last edited by
          #4

          ByRef cured the problem. I was going down fast. thanks In the actual program it is a function. I slimmed down the code for my question. Thanks for the comment though, and help.

          1 Reply Last reply
          0
          • D Dave Doknjas

            If you don't specify "ByRef" or "ByVal", then the parameter is "ByVal" by default. You want:

            Sub db_create_cs(ByRef dbc As db_connection)

            David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

            B Offline
            B Offline
            Bret Stern
            wrote on last edited by
            #5

            I thought I checked that. It fixed the problem. Thanks for the help. I sense a series of adjustments going from VB6 to VS 2008 is ahead.

            D 1 Reply Last reply
            0
            • B Bret Stern

              I thought I checked that. It fixed the problem. Thanks for the help. I sense a series of adjustments going from VB6 to VS 2008 is ahead.

              D Offline
              D Offline
              Dave Doknjas
              wrote on last edited by
              #6

              The problem is that for VB6, the default was "ByRef", but for VB.NET, the default is "ByVal".

              David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

              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