vba - VarType for user defined type -


i have user-defined objects in vba code , wondering if there way check object type is. thing like

dim myobject variant set myobject= new employee       if(myobject istype employee)                  else            else 

i thinking vartype() function, apparently won't work user defined types. there else can use?

there 2 possibilities so. following code should explain everything. see additional comments inside:

sub qtest()      dim myobject variant     set myobject = new employee      'return results immediate     debug.print typename(myobject) '>> return class name     debug.print typeof myobject employee '>>will return true      'using 'if statements', both return true      if typename(myobject) = "employee"         msgbox "ok"     end if      if typeof myobject employee         msgbox "ok"     end if  end sub 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -