VBA: How to pass arrays in Function Calls?
You are assigning the first element of an array of integers with the string
Won. This array can only hold integers. Try this...
Function Testx(Arg)
' Function should return the word "Won".
Dim Cols(3) As Integer
Call Testy(Cols())
Testx = Cols(1)
End Function
Sub Testy(Cols() As Integer)
Cols(1) = 123
MsgBox "Done" <-- Calling never gets to this line.
End Sub
--
HTH...
Jim Thomlinson
"Mac Lingo" wrote:
This code dies at the "Msgbox" Line.
Can you give me an idea why. And what do I do to make it work as it should?
Function Testx(Arg)
' Function should return the word "Won".
Dim Cols(3) As Integer
Call Testy(Cols())
Testx = Cols(1)
End Function
Sub Testy(Cols() As Integer)
Cols(1) = "Won"
MsgBox "Done" <-- Calling never gets to this line.
End Sub
Thanks,
Mac Lingo
Berkeley, CA
|