Test Objects Using TypeName

Test Objects Using TypeName

You can determine the class of an object using the TypeName function instead of the If TypeOf statement.Use the TypeOf statement to determine the type of object:

 If TypeOf myObject is myType then        ... do somethingEnd If

You can do the same with this code:

 if TypeName(myObject) = "myType" Then something ....End If

The advantage is that you don’t have to include in your project all the classes (or OCXs) that you manage.This is a good approach when writing general purpose routines, and moreover, you can use TypeName incompound tests and Select Case blocks.

See also  Why ChatGPT Is So Important Today

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist