Search code examples
vb6user-defined-types

How do I reinitialise a UDT in VB6?


I've got a loop, which is reading in a stack of XML files, for each one, it validates the data that was in the XML and loads it into some UDTs and then does some work on the data.

Then it gets back to the beginning of the loop and the UDTs still have data in from the previous XML. If that tag is defined in the new one, it overwrites, but if that tag isn't defined, then that element in the UDT is left alone.

But I can't reset the UDT by the technique I'd use for a variable (Let X = 0) unless I go through every single element of the UDT and reset the value. And doing it object-style (Set X as New UDT) doesn't work.

How do I do it?


Solution

  • Dim a new variable as the UDT and set the old one equal to the new variable.

    For instance:

    Dim XEmpty as UDT
    X = XEmpty
    

    Will reinitialise a variable X that is a UDT of type UDT.