Solved

Collections question.

Posted on 2000-04-05
2
196 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 64
MsgBox 4 68
fso.FolderExists("\\server\HiddenFolder$") 4 78
Excel VBA - Run Time error '1004' Application-defined or object-defined error 4 199
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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

860 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