In vb.net, you can address a public variable from another form using the form name along with the variable.
form2.show
form2.k = 3
However, if you use a form variable to show an instance of the form, you must use that variable name to address the public variable. Two instances of the same form are displayed in the following example. The public variable k is assigned a value of 3 only in the first instance of the form, the one from form2.show
. frm.k
can be used to assign a value to the other form.
dim frm as new form2
form2.show
frm.show
form2.k = 3
My question: Assuming only one instance of the form is shown in the application, is it reliable to address a public variable using the form name (form2.k
), or is it better to show the form with a form variable and use that to refer to the instance of the form (frm.k
)? Would the same answer apply to a property as well as a public variable?