byref 传递变量地址,不管它是数组,对象,还是其它,都可以传递。示例:Private Sub Command1_Click() Dim a(2, 2) As String a(0, 0) = "00" a(0, 1) = "01" a(0, 2) = "02" a(1, 0) = "10" a(1, 1) = "11" a(1, 2) = "12" a(2, 0) = "20" a(2, 1) = "21" a(2, 2) = "22" Call test(a)End SubPrivate Function test(ByRef aa() As String) As String Dim b As String, i As Integer, j As Integer For i = 0 To 2 For j = 0 To 2 b = b & aa(i, j) & "," Next Next MsgBox b End Function
ByRef,按地址传递,为VB的隐式声明;ByVal,按值传递,应用是需显示声明
楼主也可以这种方法实现:'Class Information Structure Type CLSINFO_ StdName() As String 'Student Name End TypeDim ClassInfo() As CLSINFO_ 'Class Information
a(0, 0) = "00"
a(0, 1) = "01"
a(0, 2) = "02"
a(1, 0) = "10"
a(1, 1) = "11"
a(1, 2) = "12"
a(2, 0) = "20"
a(2, 1) = "21"
a(2, 2) = "22" Call test(a)End SubPrivate Function test(ByRef aa() As String) As String
Dim b As String, i As Integer, j As Integer
For i = 0 To 2
For j = 0 To 2
b = b & aa(i, j) & ","
Next
Next
MsgBox b
End Function
Type CLSINFO_
StdName() As String 'Student Name
End TypeDim ClassInfo() As CLSINFO_ 'Class Information