Feb 17, 2009 #1 njahnavi Technical User Joined Dec 29, 2008 Messages 136 Location US Hi i am using vb.net version 2.0 I want to pass a combobox value from one form to another how to do it. Thanks for any help
Hi i am using vb.net version 2.0 I want to pass a combobox value from one form to another how to do it. Thanks for any help
Feb 17, 2009 #2 RiverGuy Programmer Joined Jul 18, 2002 Messages 5,011 Location US On your form without the ComboBox, create a class level variable at the top of the form: Code: Private mSomeVariable As Integer Create a property on your form without the ComboBox Code: Public Property SomeVariable() As Integer Get Return mSomeVariable End Get Set(ByVal value As Integer) mSomeVariable = value End Set End Property When you are going to open up the form without the ComboBox, set it's property with the value from your ComboBox Code: Dim NewForm As New SecondForm NewForm.SomeVariable = YourComboBox.Items(YourComboBox.SelectedIndex) You will then have access to that "mSomeVariable" (replacing the name with whatever you choose) variable in your second form. Upvote 0 Downvote
On your form without the ComboBox, create a class level variable at the top of the form: Code: Private mSomeVariable As Integer Create a property on your form without the ComboBox Code: Public Property SomeVariable() As Integer Get Return mSomeVariable End Get Set(ByVal value As Integer) mSomeVariable = value End Set End Property When you are going to open up the form without the ComboBox, set it's property with the value from your ComboBox Code: Dim NewForm As New SecondForm NewForm.SomeVariable = YourComboBox.Items(YourComboBox.SelectedIndex) You will then have access to that "mSomeVariable" (replacing the name with whatever you choose) variable in your second form.
Feb 17, 2009 1 #3 softhemc Programmer Joined Jan 23, 2009 Messages 308 Location GB A quick scan through the FAQs section of this forum revealed... faq796-5773 does this not comprehensively answer your question? Upvote 0 Downvote
A quick scan through the FAQs section of this forum revealed... faq796-5773 does this not comprehensively answer your question?