How do I reinitialise a UDT in VB6?

馋奶兔 提交于 2020-01-03 11:30:09

问题


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?


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/6229076/how-do-i-reinitialise-a-udt-in-vb6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!