?
Solved

Creating Objects at runtime, Collections

Posted on 1999-01-24
5
Medium Priority
?
147 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 30 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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