Set a type in VBA to nothing?

后端 未结 7 1310
隐瞒了意图╮
隐瞒了意图╮ 2021-02-12 10:40

I have defined a variable with an own type, say

Dim point As DataPoint

Public Type DataPoint
   list as Collection
   name as String
   number as Integer
End Ty         


        
7条回答
  •  逝去的感伤
    2021-02-12 10:57

    For that is better to use classes, you can declare a class module with the name of your type, then declare all of your members as public, then automatically you can set to nothing and new for create and delete instances.

    syntax will be somthing like this after you create the class module and named like your type:

    '
    Public List as Collection
    Public Name as String
    Public Number as Long
    
    Private Sub Class_Initialize()
    
    'Here you can assign default values for the public members that you created if you want
    
    End Sub
    

提交回复
热议问题