Solved

Collections question.

Posted on 2000-04-05
2
193 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
2 Comments
 
LVL 1

Accepted Solution

by:
phiro earned 50 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

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…
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…

759 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

18 Experts available now in Live!

Get 1:1 Help Now