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 variables thru refrence

passing variables thru refrence

Scheduled Pinned Locked Moved Visual Basic
help
4 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.
  • U Offline
    U Offline
    User 1207085
    wrote on last edited by
    #1

    Hi all, see I have class module which has a subroutine say private sub myrt() dim str as string str="just check" form1.reta(str) end sub there is a subroutine in the form (named as form1) module named as reta private sub reta(byref asd as string) asd="the return value" end sub the problem with this is that, even though the variable is passed as refrence in the subroutine, the value of str is still showing "just checking" instead of "the return value" after executing the sub reta this only happ in the class module, do it in the same nodule the problem does not exists.

    D 1 Reply Last reply
    0
    • U User 1207085

      Hi all, see I have class module which has a subroutine say private sub myrt() dim str as string str="just check" form1.reta(str) end sub there is a subroutine in the form (named as form1) module named as reta private sub reta(byref asd as string) asd="the return value" end sub the problem with this is that, even though the variable is passed as refrence in the subroutine, the value of str is still showing "just checking" instead of "the return value" after executing the sub reta this only happ in the class module, do it in the same nodule the problem does not exists.

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

      You'll have to step through your code and find the second function you defined as reta. Next, since you defined the function reta as Private in Form1, it can't be called by any code outside of Form1 class. Lastly, did you pass a reference to Form1 to your class module where myrt is defined? If not, your not using the Form1 instanace that you think you are. Forms in VB.NET do not work like they did in VB6 and below. In order to diagnose this further, we'd need to see more of your code, preferrably copied and pasted between <pre></pre> tags. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      L 1 Reply Last reply
      0
      • D Dave Kreskowiak

        You'll have to step through your code and find the second function you defined as reta. Next, since you defined the function reta as Private in Form1, it can't be called by any code outside of Form1 class. Lastly, did you pass a reference to Form1 to your class module where myrt is defined? If not, your not using the Form1 instanace that you think you are. Forms in VB.NET do not work like they did in VB6 and below. In order to diagnose this further, we'd need to see more of your code, preferrably copied and pasted between <pre></pre> tags. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

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

        thanx for the info dave, but I am using VB and not VB.Net, so the problem is comming in that, so if u have any idea, kindly reply the same

        D 1 Reply Last reply
        0
        • L Lost User

          thanx for the info dave, but I am using VB and not VB.Net, so the problem is comming in that, so if u have any idea, kindly reply the same

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

          The same rules for public/private subs and functions as well as passing parameters apply to both VB and VB.NET. We'll have to see the code your using to see what's going on. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          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