Solved

What  type of object

Posted on 2002-04-25
7
153 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
  • 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now