Andy 胡

导航

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

posted on 2020-09-11 22:56  talkwah  阅读(1863)  评论(0编辑  收藏  举报