Scope of Public Shared

TomPhillips

Active member
Joined
Feb 24, 2005
Messages
33
Programming Experience
10+
I declare a Public Shared variable strX as string in Form frm1 and set it's value = "X".

Dim frm2 as new Form2
frm2.showdialog()

In Form2 see frm1.strX as "X"
change frm1.strX = "Y"
Close frm2

Why is strX still = "X" when I get back to frm1?

Work around: In Form2 declare Public Shared strX2 as string. Set it = "Y" then

in frm1, after frm2.showdialog()
me.strX = frm2.strX2

This seems goofy, why is Public Shared one way? You can see it and change it down scope, but when you go back up the change isn't there.
 
Back
Top