Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declare variables to a code? Pas Excel Discussion (Misc queries) 6 April 10th 10 01:14 PM
Declare Variables in Array Mike H. Excel Discussion (Misc queries) 2 March 11th 09 12:33 PM
How to declare a dynamic array Peter Rooney Excel Discussion (Misc queries) 4 April 13th 05 01:25 PM
How to declare Multi-dimensional dynamic array? Terence Excel Programming 1 August 11th 03 04:55 AM
declare a two dimenssion array Tom Ogilvy Excel Programming 0 July 8th 03 03:06 PM


All times are GMT +1. The time now is 07:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"