Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

how do you expose the properties of form controls

in Access I could do something like this:

Dim ctl as control
dim prp as property

For each ctl in me.controls
    For each prp in ctl.Properties
         debug.Print ctl.name & vbtab & prp.name
    Next prp
Next ctl

I can't seem to do this in VB6. I want to be able to loop through the controls on a form, determine if they are a certain type eg. Textbox, command button etc and then set properties on the controls like ForeColor
0
Mach1pro
Asked:
Mach1pro
  • 3
1 Solution
 
leclairmCommented:
If you want to find out the type of control, use something like:

Dim ctl As Control
For Each ctl In Me.Controls
    If TypeOf ctl Is TextBox Then
        MsgBox (ctl.Name)
    End If
Next ctl
0
 
leclairmCommented:
To set the properties, just use the ctl object directly.

For Each ctl In Me.Controls
    If TypeOf ctl Is TextBox Then
        ctl.ForeColor = &HC0&
    End If
Next ctl
0
 
leclairmCommented:
Any luck??
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now