passing variables thru refrence
-
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.
-
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.
You'll have to step through your code and find the second function you defined as
reta
. Next, since you defined the functionreta
asPrivate
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 wheremyrt
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 -
You'll have to step through your code and find the second function you defined as
reta
. Next, since you defined the functionreta
asPrivate
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 wheremyrt
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 -
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
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