![]() |
Variable help
What does it mean when you have a variable with parens? Like declaring v() as
Variant, and then using the variable v with another variable it seems right beside it, like v(i)? Can anyone help? |
Variable help
What you are describing is a Dynamic Array.
Search Excel Help for this: declaring arrays Post back with any questions. *********** Regards, Ron XL2002, WinXP-Pro "Mike" wrote: What does it mean when you have a variable with parens? Like declaring v() as Variant, and then using the variable v with another variable it seems right beside it, like v(i)? Can anyone help? |
Variable help
The brackes denote an array. An array is a collection of like varaibles, for
example: dim aryMyIntegers(10) as integer declares an array of 10 integers. The line aryMyIntegers(3) references the 4th element of the array since the numbering starts at zero. -- HTH... Jim Thomlinson "Mike" wrote: What does it mean when you have a variable with parens? Like declaring v() as Variant, and then using the variable v with another variable it seems right beside it, like v(i)? Can anyone help? |
Variable help
So what does it mean when you declare it with empty brackets? ()
"Jim Thomlinson" wrote: The brackes denote an array. An array is a collection of like varaibles, for example: dim aryMyIntegers(10) as integer declares an array of 10 integers. The line aryMyIntegers(3) references the 4th element of the array since the numbering starts at zero. -- HTH... Jim Thomlinson "Mike" wrote: What does it mean when you have a variable with parens? Like declaring v() as Variant, and then using the variable v with another variable it seems right beside it, like v(i)? Can anyone help? |
Variable help
OK, Mike
Copied from Excel Help: ------------------------------ Declaring a Dynamic Array By declaring a dynamic array, you can size the array while the code is running. Use a Static, Dim, Private, or Public statement to declare an array, leaving the parentheses empty, as shown in the following example. Dim sngArray() As Single Note You can use the ReDim statement to declare an array implicitly within a procedure. Be careful not to misspell the name of the array when you use the ReDim statement. Even if the Option Explicit statement is included in the module, a second array will be created. In a procedure within the array's scope, use the ReDim statement to change the number of dimensions, to define the number of elements, and to define the upper and lower bounds for each dimension. You can use the ReDim statement to change the dynamic array as often as necessary. However, each time you do this, the existing values in the array are lost. Use ReDim Preserve to expand an array while preserving existing values in the array. For example, the following statement enlarges the array varArray by 10 elements without losing the current values of the original elements. ReDim Preserve varArray(UBound(varArray) + 10) Note When you use the Preserve keyword with a dynamic array, you can change only the upper bound of the last dimension, but you can't change the number of dimensions. ------------------------------ *********** Regards, Ron XL2002, WinXP-Pro "Mike" wrote: So what does it mean when you declare it with empty brackets? () "Jim Thomlinson" wrote: The brackes denote an array. An array is a collection of like varaibles, for example: dim aryMyIntegers(10) as integer declares an array of 10 integers. The line aryMyIntegers(3) references the 4th element of the array since the numbering starts at zero. -- HTH... Jim Thomlinson "Mike" wrote: What does it mean when you have a variable with parens? Like declaring v() as Variant, and then using the variable v with another variable it seems right beside it, like v(i)? Can anyone help? |
All times are GMT +1. The time now is 12:02 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com