我已经声明了一个 UDT,我需要用 UDT 的特定记录初始化一个数组,我将如何在模块级别执行此操作。
这是我尝试过的
Public Type MyType
id As Integer
name As String
values As Double
End Type
private MY_TYPES(1) As MyType
My_TYPES(0) = newMyType(1, "Item 1", 15.9)
My_TYPES(1) = newMyType(2, "Item 2", 30.2)
Private Function newMyType(byval id as Integer, byval name as String, _
byval v as Double) As MyType
Dim t As MyType
t.id = id
t.name = name
t.value = v
newMyType = t
End Function
我得到的错误是Invalid outside procedure
如您所见,我尝试重现 java 的静态初始化,Collection
例如 aList
或 Set
我想将集合公开为常量,我怎么能做到这一点?