Solved

Creating Objects at runtime, Collections

Posted on 1999-01-24
5
138 Views
Last Modified: 2010-05-03
I am reading categories from a table, I would like to create
a checkbox for each category on a form so that the user can select which categories they wish to view. Categories can be added or deleted, therefor the control need to be built at runtime.
0
Comment
Question by:paulmck
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 

Author Comment

by:paulmck
ID: 1470377
Edited text of question
0
 

Author Comment

by:paulmck
ID: 1470378
Adjusted points to 8
0
 
LVL 4

Expert Comment

by:mcix
ID: 1470379
One approach would be to use a standard ListBox Control and set the Style to CheckBox.

You could then determine which categories are selected like this:

For i = 0 To List1.ListCount - 1
    If List1.Selected(i) Then
        MsgBox List1.List(i)
    End If
Next i

0
 
LVL 12

Accepted Solution

by:
mark2150 earned 10 total points
ID: 1470380
VB5 requires you to have a control array already on your form. Once it's there you can simply add elements to it for as many items as you wish. Difficulty is that the code for the control cannot be added dynamically so your event handling has to be smart enough to behave correctly no matter how many elements are present. .LBound and .UBound properties will tell your routine how many controls have been created in the array.

Thats a *lot* of help for a lousy 8 point question!

M

0
 

Author Comment

by:paulmck
ID: 1470381
Wasn't quite what i had in mind but a good solution. Thanks for your prompt answer.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question