procedure call with Array arguments

grenee

Registered User.
Local time
, 17:35
Joined
Mar 5, 2012
Messages
212
Good day all.
My problem is in the extract from my program below.
The procedure call "Call RearrangeCoordinates(RearrangeCoords(), ReturnCoords())" return a message "Type mismatched: Array or user-defined type expected"
Are there any views as to why the message is being displayed?

Private Sub CommandButton1_Click()

Dim ReturnCoords As Variant

Dim ...........................................

ArrayLength = UBound(ReturnCoords)
ReDim RearrangeCoords(0 To ArrayLength) As Variant
Call RearrangeCoordinates(RearrangeCoords(), ReturnCoords())
..........................................

End Sub


Public Sub RearrangeCoordinates(ByRef RearCoord() As Variant, ByRef ReturnCoords() As Variant)

For q = 0 To 8 Step 2
RearrangeCoords(q) = ReturnCoords(q + 1)
RearrangeCoords(q + 1) = ReturnCoords(q)
Next q

End Sub
 
Hi,
First, you should read the thread CJ_London pointed.

Here you declare a Variant type variable:
Code:
Dim ReturnCoords As Variant
The function expects an array of Variants:
Code:
Public Sub RearrangeCoordinates(ByRef RearCoord() As Variant, ByRef [COLOR="Red"]ReturnCoords[B]()[/B] As Variant[/COLOR])
and you pass to the function non existing array:
Code:
Call RearrangeCoordinates(RearrangeCoords(), [COLOR="red"]ReturnCoords[B][U]()[/U][/B][/COLOR])'ReturnCoords is not an array!
Your declaration should probably be:
Code:
Dim ReturnCoords As Variant[COLOR="Red"]()[/COLOR]
 

Users who are viewing this thread

Back
Top Bottom