[RESOLVED] Create combobox object in code
I am using VB6, SP5.
I need to call a routine that takes a combobox as a parameter. I am doing something like this:
Dim cboTest as ComboBox
sLoadItems cboTest
if cboTest.ListCount >0 then
msgbox cboTest.ListCount & " items were loaded"
else
msgbox "No items were loaded"
end if
Seems simple enough; however, it produces error 91, Object not set. I tried changing the declaration to the following:
Dim cboTest as New ComboBox
Now it gives me the error that I am using the New keyword incorrectly.
Set cboTest = new ComboBox
This produces the same results. What am I missing?
I do not want to add the combo box to the GUI; I do not have one since my code resides in a module. Thank you, Saga
Re: Create combobox object in code
You have declared the object but not created it. You can create the combo using the controls collection.
Code:
Dim cboTest As ComboBox
Set cboTest = Controls.Add("VB.Combobox", "cboTest")
Re: Create combobox object in code
Huh, for some reason my post did not appear. Anyways...
That got it to work! Thanks! Incredible the stuff that I forget when I don't use it. Saga