function a(b)
msgbox b.name
end functionb可能是数组变量,可能是字符串变量,也可能是字节变量,
比方
dim cc(10) as byte
cc(1)=1
call a(cc)
如何在 a中获得 参数b所引用的变量名?
------------------------------------
msgbox b.name
end functionb可能是数组变量,可能是字符串变量,也可能是字节变量,
比方
dim cc(10) as byte
cc(1)=1
call a(cc)
如何在 a中获得 参数b所引用的变量名?
------------------------------------
Dim a() As Integer
Dim b() As String
Dim c() As Byte
Dim test As VariantDebug.Print TypeName(test)
test = a
Debug.Print TypeName(test)
test = b
Debug.Print TypeName(test)
test = c
Debug.Print TypeName(test)输出:
Empty
Integer()
String()
Byte()
可采用变通的方法实现:(内外约定好)
Private Sub Command1_Click()
Dim a() As Integer
Dim b() As String
Dim c() As Byte
Test (a)
Test (b)
Test (c)
End Sub
Function Test(obj As Variant)
Select Case TypeName(obj)
Case "Integer()"
MsgBox "a"
Case "String()"
MsgBox "b"
Case "Byte()"
MsgBox "c"
End Select
End Function