Passing array to function returns “Compile error: Type mismatch: array or user-defined type expected”

后端 未结 1 1773
后悔当初
后悔当初 2021-01-25 02:35

I have following subroutine which prints the array elements:

Sub printArray(arr() As Variant)
  Dim i, lowerBound, upperBound As Integer
  lowerBound = LBound(ar         


        
相关标签:
1条回答
  • 2021-01-25 03:34

    A Variant (which may happen to contain an array) is not the same as an array of Variants. You need to change this line:

    Dim arr As Variant
    

    to this:

    Dim arr() As Variant
    
    0 讨论(0)
提交回复
热议问题