问题
I'm trying to assign array result of function to an array. It works fine, if i try to assign one element of result array to my array, but it returns error while trying to assign whole result array to my array ("Can't assign to array").
Sub test()
Dim lol(6) as Double
lol = Hehe2()
End Sub
Function Hehe2() As Double()
Dim Zliczacz(1 To 6) As Double
Zliczacz(1) = 1 / 2
Zliczacz(2) = 1 / 2
Zliczacz(3) = 1 / 2
Zliczacz(4) = 1 / 2
Zliczacz(5) = 1 / 2
Zliczacz(6) = 1 / 2
Hehe2 = Zliczacz()
End Function
回答1:
You can only assign one array to another if the receiving array is declared as dynamic and of the same type. Yours is fixed, so it won't work. You need to use:
Dim lol() as Double
来源:https://stackoverflow.com/questions/34317067/cant-assign-array-result-of-function-to-an-array