Declare an Array() ????

A

Andoni

Hi, and Many Thanks in advance



what's wrong here:

I would like to declare the XeY array properly, but don't know how


Sub Myarray()
Dim XeY '????????????????(7) As Variant
Dim X As Byte
X = Int((2* Rnd) + 1)
Dim Y As Byte
Select Case X
Case 1: XeY = Array(2, 1, 0, -1, -1, 0, 1, 2)
Case 2: XeY = Array(-1, 0, 1, 2, 1, 0, -1, -2)
End Select
For Y = LBound(XeY) To UBound(XeY)
MsgBox XeY(Y)
Next Y
End Sub


MyArray sub is just one example, has nothing to do with my request,
only want to know how can I declare the XeY array properly
when XeY will have always 7 elements ranging each element from 0 to 9.

XeY(7) as Byte does not wor
 
T

Tom Ogilvy

declare it as variant. You can declare it as a variant array in xl2000 or
later

Dim XeY() as variant

but you gain nothing doing this and make it incompatible with xl97.

Sub Myarray()
Dim XeY as variant
Dim X As Byte
X = Int((2* Rnd) + 1)
Dim Y As Byte
Select Case X
Case 1: XeY = Array(2, 1, 0, -1, -1, 0, 1, 2)
Case 2: XeY = Array(-1, 0, 1, 2, 1, 0, -1, -2)
End Select
For Y = LBound(XeY) To UBound(XeY)
MsgBox XeY(Y)
Next Y
End Sub
 
Top