Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What  type of object

Posted on 2002-04-25
7
Medium Priority
?
163 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
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!

 
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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

618 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