Solved

What  type of object

Posted on 2002-04-25
7
160 Views
Last Modified: 2010-05-02
I am passing a variant to a procedure. In the procedure I want to find out what type of an object I have passed. I am passing textboxes, combo boxes and datepickers. Each are handled slightly differently in the procedure. I know the is a function to tell what kind of object something is. What is it and will it work in this case.

Edel
0
Comment
Question by:edel2000ie
[X]
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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 13

Expert Comment

by:crazyman
ID: 6967974
debug.print typename(object)

or

if typeof object is textbox then
end if
0
 
LVL 2

Expert Comment

by:corvanderlinden
ID: 6967982
Vartype(object)

Returns an Integer indicating the subtype of a variable.


0
 
LVL 2

Expert Comment

by:corvanderlinden
ID: 6967983
Sorry, VarType is not the right one in this case

Use crazyman's TypeOf
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 6968011
TypeName is probably better in this instance:

Public Sub DoSomething(ByRef Something As Variant)
Select Case TypeName(Something)
Case "TextBox"
Case "CommandButton"
Case "Timer
Case "FileListBox
Case "DirListBox
Case "DriveListBox
Case "HScrollBar
Case "VScrollBar
Case "PictureBox
Case "CommandButton
Case "Frame
Case "TextBox
Case "OptionButton
Case "CheckBox
Case "ComboBox
Case "ListBox
Case "HScrollBar
Case "TabStrip
Case "Toolbar
Case "TreeView
Case "ProgressBar
Case "StatusBar
Case "ImageList
Case "ListView
Case "ImageCombo
Case "MonthView
Case "FlatScrollBar
Case "UpDown
Case "DTPicker
Case "Adodc
Case "OLE
Case "Image
Case "Line
Case "Shape
Case "Label
End Select
End Sub

0
 

Author Comment

by:edel2000ie
ID: 6968074
Thank you Tim Cottee. Excellent answer. I was going with Typeof but your example suits perfectly. All help from everyone much appreciated

Bye

Edel
0
 
LVL 13

Expert Comment

by:crazyman
ID: 6968076
;o(
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6968100
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…

691 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