![]() |
|
|
#1
|
|||
|
|||
|
I am trying to define an array as the following:
Dim MyArray(x to x+10) as integer But it seems that VB does not allow me to do so. I wonder if there is a way to circumvent this so that I can greatly simplify my code using the index number to do something? Otherwise it will be quite tedious. Thanks |
|
#2
|
||||
|
||||
|
ReDim will do the trick.
__________________
If once a man indulges himself in murder, very soon he comes to think little of robbing; and from robbing he comes next to drinking and Sabbath-breaking, and from that to incivility and procrastination. Once begun upon this downward path, you never know where you are to stop. Many a man has dated his ruin from some murder or other that perhaps he thought little of at the time. |
|
#3
|
||||
|
||||
|
Quote:
Dim MyArray() as Integer Then after the value of x has been determined, put in the line ReDim MyArray(x to x+10) Brad
__________________
Brad Gile, FSA, MAAA Affiliate Member of the CAS Dedicated Retired Actuary Spoiler: Spoiler: |
|
#4
|
||||
|
||||
|
LLJ,
I'm not sure why you want to delare an array from x to x+10. If you know you want an array with 11 elements simply declare the array as MyArray(1 to 11). The traditional purpose for ReDim is when you need an array with a variable number of elements. |
|
#6
|
||||
|
||||
|
Quote:
Brad
__________________
Brad Gile, FSA, MAAA Affiliate Member of the CAS Dedicated Retired Actuary Spoiler: Spoiler: |
|
#7
|
|||
|
|||
|
Thanks all-
I cannot say too much about the details. I wanted to do this because I retrive the value of x and manipulate it a lot, if I make it array(1 to 10), I'll have to adjust the index to the X I want all the time. BTW,it is already working! Thanks |
|
#8
|
||||
|
||||
|
Quote:
Let the compiler do the chores, and let people think! Why does perl provide hashes when the programmer can easily implement them him/herself? Because if you want to write Phone('fred')=15, then by golly why not, and let the language do the hard work of writing the optimal code.
__________________
Sticks and Stones may break my bones, but Markov Chains excite me. |
|
#9
|
|||
|
|||
|
Quote:
|
|
#10
|
||||
|
||||
|
Quote:
http://msdn.microsoft.com/msdnmag/issues/02/02/NET/ Quote:
__________________
Brad Gile, FSA, MAAA Affiliate Member of the CAS Dedicated Retired Actuary Spoiler: Spoiler: |
![]() |
| Thread Tools | |
| Display Modes | |
|
|