Solved

Control type?

Posted on 2001-08-11
5
185 Views
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
next

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

Expert Comment

by:PaulHews
ID: 6375872
This help?

Option Explicit

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

Expert Comment

by:PaulHews
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
0
 
LVL 1

Author Comment

by:BlaZer
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...
0
 
LVL 38

Accepted Solution

by:
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.
0
 
LVL 1

Expert Comment

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

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

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Macro which automatically sends attachment to Outlook 14 69
VBA/SQL - Connect to SQL server and pull data 4 108
Access query that references subform 5 47
Spell Check in VB6 13 112
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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

776 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