Link to home
Start Free TrialLog in
Avatar of BlaZer
BlaZer

asked on

Control type?

How can i at runtime deternimate what control type a object is?

for examble

For each object in me
msgbox object.type
next

ive tried alot og of things...using the typelib is one of them..but that dosnt work with calender controls....
Avatar of PaulHews
PaulHews
Flag of Canada image

This help?

Option Explicit

Private Sub Command1_Click()
    Dim ctl As Control
    For Each ctl In Controls
        Debug.Print TypeName(ctl)
    Next
   
End Sub
Or this?

Dim I   ' Declare variable.
   For I = 0 To Frm.Controls.Count - 1
      If Not TypeOf Frm.Controls(I) Is Menu Then
         Frm.Controls(I).Enabled = State
      End If
   Next I
Avatar of BlaZer
BlaZer

ASKER

number one comment works perfect..i dont know i could add a more question, but do u know how to deternimate the parent of the name? Like vb.commandbutton or MSComctlLib.TreeCtrl ?

if u cant/dont want to answer that ill just give u the points...
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
'This should work fine
  Dim cntl As Control

  For Each cntl In Controls
     Debug.Print TypeName(cntl)
  Next