举个例子: Dim aa(1 To 2) As String aa(1) = "a" aa(2) = "b" Call MyTest(aa)
所有的office安装盘都带有帮助
Private Sub CommandButton1_Click() Dim str(1) As String str(0) = "a" str(1) = "b" Call a(str)End SubPrivate Function a(str() As String) As Object Dim i As IntegerFor i = 0 To UBound(str) Debug.Print str(i)Next End Function
给一个function传字符串数组str()当参数,调用function时怎么写?是 getFunction(str)还是getFunction(str())。
写该function时参数部分如何写?是getFunction(str AS String)吗?
UBound(A, 1) = 100 一维最大下标然后UBound - LBound + 1就是一维的维数
Public Function MyTest(Stra() As String)
...
End Function
建议lz多看看VBA帮助文档, 这些都是基础...
Dim aa(1 To 2) As String
aa(1) = "a"
aa(2) = "b"
Call MyTest(aa)
Dim str(1) As String
str(0) = "a"
str(1) = "b"
Call a(str)End SubPrivate Function a(str() As String) As Object
Dim i As IntegerFor i = 0 To UBound(str)
Debug.Print str(i)Next
End Function