I have this set of VBA functions:
Sub x()
Dim a() As Variant
z y(a)
End Sub
Function y(a() As Variant) As Variant
y = a
End Function
Function z(a() As Variant) As Variant
z = a
End Function
When I run x()
, the line zy(a)
throws an error:
Type mismatch: array or user-defined type expected
I guess this is happening because z()
is expecting an array as an argument but the return value of y()
is a variant, not an array. I'm not sure how to make clear that y()
returns an array of variants--did I declare it wrong?
Though your code does nothing, this will stop the error:
Sub x()
Dim a() As Variant
z y(a)
End Sub
Function y(a() As Variant) As Variant()
y = a
End Function
Function z(a() As Variant) As Variant()
z = a
End Function
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.