ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Declare an Array() ???? (https://www.excelbanter.com/excel-programming/308537-declare-array.html)

Andoni[_23_]

Declare an Array() ????
 
Hi, and Many Thanks in advance



what's wrong he

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

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Declare an Array() ????
 
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

--
Regards,
Tom Ogilvy

"Andoni " wrote in message
...
Hi, and Many Thanks in advance



what's wrong he

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, I
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 work


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 01:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com