F
fisherofsouls
I have a really silly error which is killing me !
When I pass a filled array to a function, it loses all its content once
inside the function, as follows:
*** START CODE SNIPPET
Option Base 1
Sub MyRoutine
ReDim MyArray(3) As Variant
For x = 1 To 3
MyArray(x) = x
Next x
a = bAllFiguresUnique(MyArray()) '<== UBOUND HERE IS 3
End Sub
Function bAllFiguresUnique(ParamArray MyArray() As Variant) As Boolean
bAllFiguresUnique = True
For x = 1 To UBound(MyArray()) '<== UBOUND HERE IS 0
DoEvents
For y = 1 To UBound(MyArray())
DoEvents
If MyArray(x) = MyArray(y) Then
If x = y Then
'Ignore
Else
bAllFiguresUnique = False
Exit Function
End If
End If
Next y
Next x
End Function
*** END CODE SNIPPET
I must be doing something stupid, but I can't work out what !
Thanks in advance for all constructive suggestions.
Nick
When I pass a filled array to a function, it loses all its content once
inside the function, as follows:
*** START CODE SNIPPET
Option Base 1
Sub MyRoutine
ReDim MyArray(3) As Variant
For x = 1 To 3
MyArray(x) = x
Next x
a = bAllFiguresUnique(MyArray()) '<== UBOUND HERE IS 3
End Sub
Function bAllFiguresUnique(ParamArray MyArray() As Variant) As Boolean
bAllFiguresUnique = True
For x = 1 To UBound(MyArray()) '<== UBOUND HERE IS 0
DoEvents
For y = 1 To UBound(MyArray())
DoEvents
If MyArray(x) = MyArray(y) Then
If x = y Then
'Ignore
Else
bAllFiguresUnique = False
Exit Function
End If
End If
Next y
Next x
End Function
*** END CODE SNIPPET
I must be doing something stupid, but I can't work out what !
Thanks in advance for all constructive suggestions.
Nick