0

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
  • 1
    Remove brackets from the assignment: Hehe2 = Zliczacz Commented Dec 16, 2015 at 16:24

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.