Solved

Creating Objects at runtime, Collections

Posted on 1999-01-24
5
123 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
Comment Utility
Edited text of question
0
 

Author Comment

by:paulmck
Comment Utility
Adjusted points to 8
0
 
LVL 4

Expert Comment

by:mcix
Comment Utility
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
Comment Utility
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
Comment Utility
Wasn't quite what i had in mind but a good solution. Thanks for your prompt answer.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 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

11 Experts available now in Live!

Get 1:1 Help Now