Control type?

Posted on 2001-08-11
Last Modified: 2010-05-02
How can i at runtime deternimate what control type a object is?

for examble

For each object in me
msgbox object.type

ive tried alot og of things...using the typelib is one of them..but that dosnt work with calender controls....
Question by:BlaZer
  • 3
LVL 38

Expert Comment

ID: 6375872
This help?

Option Explicit

Private Sub Command1_Click()
    Dim ctl As Control
    For Each ctl In Controls
        Debug.Print TypeName(ctl)
End Sub
LVL 38

Expert Comment

ID: 6375875
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

Author Comment

ID: 6376470
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...
LVL 38

Accepted Solution

PaulHews earned 50 total points
ID: 6376479
I don't know how to determine that.  There may be some trick with type library code, but I have no experience with it.

Expert Comment

ID: 6376871
'This should work fine
  Dim cntl As Control

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

911 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

19 Experts available now in Live!

Get 1:1 Help Now