-
Jul 22nd, 2014, 02:25 PM
#1
Thread Starter
Member
[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
-
Jul 22nd, 2014, 02:59 PM
#2
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")
-
Jul 22nd, 2014, 03:41 PM
#3
Thread Starter
Member
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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|