vba 如何将数组作为参数

2024-11-24 00:27:43
推荐回答(2个)
回答1:

Option Explicit

Type test
a(10) As String
End Type

Sub test()
Dim c As test
Dim i As Integer
For i = 0 To 10
c.a(i) = i ^ 2
Next

Call F1(c)
End Sub

Function F1(b As test)
Dim i As Integer
For i = 0 To UBound(b.a)
Debug.Print b.a(i)
Next。

回答2:

Option Explicit

Type test
a(10) As String
End Type

Sub test()
Dim c As test
Dim i As Integer
For i = 0 To 10
c.a(i) = i ^ 2
Next

Call F1(c)
End Sub

Function F1(b As test)
Dim i As Integer
For i = 0 To UBound(b.a)
Debug.Print b.a(i)
Next
End Function

这样算不算