[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


Control type?

Posted on 2001-08-11
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

650 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