Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 937
Richard Gadsden Avatar asked Jun 03 '11 15:06

Richard Gadsden


2 Answers

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.

like image 59
Richard Gadsden Avatar answered Oct 04 '22 14:10

Richard Gadsden


You can use an empty utility function that simply returns the UDT

public function newTFoo() as TFoo
'//
end function


dim t as TFoo
t.x = 1234 ...
t = newTFoo()
'// t is reset
like image 44
Alex K. Avatar answered Oct 04 '22 14:10

Alex K.