View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
vivmaha vivmaha is offline
external usenet poster
 
Posts: 42
Default VBA.convertFromJava("instanceof")=?

Cool.

Thanks man.

"Chip Pearson" wrote:

You can use TypeName to get the name of the variable type. E.g.,

Dim V As String
Debug.Print "TypeName: " & TypeName(V)

For object type variables only (not intrinsic variables), you can use the
TypeOf operator to get the type (as long as the object is not Nothing):

Dim V As Range
Set V = Range("A1")
Debug.Print "TypeName: " & TypeName(V)
Debug.Print "TypeOf Is Range: " & TypeOf V Is Range

When working with object variables, TypeOf is better than TypeName because
you can prefix a typelib to the object type to ensure that you have the
right object type. For example, both the Excel and the MSForms libraries
have an object named CheckBox. With TypeName, you will get only the string
"CheckBox" as the result. You don't know whether it is a Excel CheckBox or
an MSForms CheckBox. With TypeOf, you can specifiy the typelib. E.g.,

If TypeOf V Is MSForms.CheckBox Then
' do something


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)








"vivmaha" wrote in message
...
Hi,

In java, I use the instanceof keyword to check if an object is a certain
type of class.

So you can do things like:
if (s instance of string) then output("String!!!") else output("Needs a
string")

Whats the equivalent in VBA?

Thanks.