?
Solved

What  type of object

Posted on 2002-04-25
7
Medium Priority
?
162 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 43

Accepted Solution

by:
TimCottee earned 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 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