VBA中的结构体

结构体必须放在“模块”中:

Type Org
    tag As String
    person As New Collection
End Type

使用:

Sub testType()
    Dim x As Org
    x.tag = "ft"

    x.person.Add ("A")
    x.person.Add ("B")

    Debug.Print ("name = " & x.tag)
    Debug.Print ("count = " & x.person.count)
    For i = 1 To x.person.count
        Debug.Print (x.person.Item(i))
    Next
End Sub
上一篇:VBA入门


下一篇:VBA实例:高考分数投档指数分析(模块3.同步代码部分)