Here’s some simple code in Test.bas:
Public Type MY_RECORD Field1 as String Field1 as StringEnd Typein frmTest.frmGeneral DeclarationsPrivate mArrayOfRecords() as MY_RECORDForm_Load 'this line of code BOMBS If IsEmpty(mArrayOfRecords) then 'dimension it End IfEnd Sub
OK, Why can’t I check if an array of user defined types has been initialized? IsEmpty does not work, nor does TypeName, VarType or any other type checking function. I get errors when I attempt to check the state of an un-initialized array of UDT’s. Any explanations?
Typically, UDT members are initialized the same way that regular variables of the same type are (i.e., strings are empty strings, numbers are zero, etc.).
The best way to check your UDT is to either check the individual members or to add an extra member that can hold a true/false value to indicate if the UDT has been initialized.