Marc said:
Great...any idea how I access this though?
Ok...
First, you've been asking many very basic questions. I think you need
to sit and just read through some basic tutorials or documents.
Now, I'll answer your question
A Form has a property named "Controls". If you have a form named FormA,
you access it by typing "FormA.Controls", or "Me.Controls" if the code
is located in FormA.
"Controls" will return a collection of all the UI controls on the form.
To find all of the buttons on a form, you have to look at the items in
this collection and see which of them are buttons.
You can use the "For Each" loop to do this (I can't explain it all
here, MSDN probably has good documentation on it).
It looks like this:
For each Ctrl As Control in Me.Controls
if TypeOf Ctrl Is Button then
'Do some special button-processing code here.
end if
next
This code represents a loop that looks at each Control in a form's
Controls Collection.
For each of the controls, it check to see if it is a button, and if it
is, you can put your own code in there.
About the syntax:
- "For Each" will iterate through a collection of somethings.
- "Ctrl As Control" will create a new variable named "Ctrl" of type
"Control". "Ctrl" will refer to the object in the collection that is
currently being inspected.
- "in Me.Controls" means you will loop through all of the objects in
"Me.Controls"
Hope this helps.