Solved

Creating Objects at runtime, Collections

Posted on 1999-01-24
5
126 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MsgBox 2 47
Excel - Save a copy of work book 13 82
Modifying Conditional Format from VBA code 3 48
Add and format columns in vb6 7 46
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now