Lets say your neighboors have a boy named Bob. Any you have a boy named Bob. They are both humans, they both have the identifier "Bob", but they are most definately, not the same being.
In VB6 the way forms were accessed was always Singleton. No mater where you called Form1 from, it was always the 1 Form1 there was.
In VB.Net everything (Including forms!!!) is object oriented. If Form1 is the name of the class, you could have 50 different variables of type Form1, each of them completely independant from all of the others. You could show them, you could populate combo boxes, but you have to work with the correct one.
So, here is what I would suggest, if your method is in the Form1 Class, us the
Me keyword. That will always reference the instance that the sub is a part of. Like so:
Code:
Public Sub BuildCombo()
me.Combo1.items.Add("Apple")
me.Combo1.items.Add("Grapes")
me.Combo1.items.Add("Rings")
End Sub
If it's not, then I would suggest passing the combo box into the sub, like so:
Code:
Public Sub BuildCombo(byref cmbFood as ComboBox)
cmbFood.items.Add("Apple")
cmbFood.items.Add("Grapes")
cmbFood.items.Add("Rings")
end sub
-Rick
----------------------
![[banghead] [banghead] [banghead]](/data/assets/smilies/banghead.gif)
If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum
![[monkey] [monkey] [monkey]](/data/assets/smilies/monkey.gif)
I believe in killer coding ninja monkeys.
![[monkey] [monkey] [monkey]](/data/assets/smilies/monkey.gif)