Passing and determining different types of object classes to populate a userform

  • So I've been using object classes with much success but one thing that is currently holding me up is passing different types of object classes to a userform and determining the type, if that is even possible. I want to customize the userform when it loads based upon the type of object that would be passed from another userform but am not sure how to go about this or if it is even possible. The only way I can currently think to do it is create a global object variable and check if it is not nothing and go from there but wondering if there is a more direct way to pass to the userform.


    Thanks

  • You can use TypeOf or Typename to determine the type of an object. (Strictly speaking, TypeOf actually checks if an object implements a specific interface, rather than testing its actual type, but it should work for your purposes).

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Thanks, though I am still having trouble. How can I pass a class object without specifying it's type or am I supposed to be doing this differently? I've tried



    I get runtime error 438, Object doesn't support this property or method.


    Thanks for your help

  • You only use brackets when calling a routine if:

    1. You are using the Call keyword; or

    2. You are using the result of a Function; or

    3. You are explicitly trying to evaluate/dereference the argument you are passing.


    In this case, none of those are true, so your calling line should just be:


    Code
    1. Test_Object_Type test_obj

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why