?
Solved

Collections question.

Posted on 2000-04-05
2
Medium Priority
?
201 Views
Last Modified: 2010-05-02
Is it possible to add different types of controls to a single collection? For example i would like to add an array of textboxes, check boxes, and option boxes to the same collection so I can loop through the collection and set properties of each control. Also is it possible to tell what type of control it is as you are looping throught the collection? Please provide code. Thanks
0
Comment
Question by:Jaysor
[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
2 Comments
 
LVL 1

Accepted Solution

by:
phiro earned 150 total points
ID: 2687465
Something like this :

**********START CODE

dim o as Label
dim c as new Collection
dim iTeller as integer
dim Enumerator as Object

for iTeller=0 to 100
  Set o = new Label
  c.Add o , Cstr(iTeller)
next iTeller

dim o2 as ComboBox

for iTeller=101 to 200
  Set o = new ComboBox
  c.Add o , Cstr(iTeller)
next iTeller

for each Enumerator in c
  if Enumerator is TypeOf Label
    'Do stuff with your label
  endif

  if Enumerator is TypeOf ComboBox
     'Do stuff with you ComboBox
  endif
next

************END CODE

0
 

Author Comment

by:Jaysor
ID: 2687606
Your syntax is wrong for the If statements it should read

if TypeOf Enumerator is Label then
end if


but you helped me out so thanks..
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

770 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