Excel VBA – Initializing Empty User Types and Detecting Nulls

excelinitializationuser-defined-typesvba

I have created a user defined type to contain some data that I will use to populate my form. I am utilizing an array of that user defined type, and I resize that array as I pull data from an off-site server.

In order to make my program easier to digest, I have started to split it into subroutines. However, when my program is initialized, I cannot tell when a particular array has been initialized, and so I cannot be certain that I can call a size function to see if the array is empty.

Is there a way to initialize an empty user type or detect a null user type? Currently, I am hard-coding it in and I would prefer a more elegant solution.

Best Solution

In addition to isempty(array) solution -

If IsNull(array) then 

   msgbox "array is empty"

End If