Question getting value from one form to another

svibuk

Active member
Joined
Jul 15, 2008
Messages
31
Programming Experience
1-3
in my vb.nt windows application i have a dropdown in form1
i need to pass this value to form2
in form2 load event
i tried
dim drpval=form1.dropdown1.selectedvalue
 
Make a public property on form 1 with the value and call form1.property from form 2

Or create a constructor on form 2 that takes the variable when created.

Sent from my XT910 using Tapatalk 2
 
Or...

Dim idx = Form1.dropdown1.SelectedIndex
Dim drpval = Form1.dropdown1.Items(idx)
 
If you want it on formload, I would probably use the constructor option.
passing values back to form1 from form2 is pretty much the same as first option, properties on the closing form remain accessible until its garbage collected.
 
Back
Top