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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default 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?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default 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?



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
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
variable height variable width stacked bar charts ambthiru Charts and Charting in Excel 3 January 18th 06 11:41 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM


All times are GMT +1. The time now is 06:41 PM.

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

About Us

"It's about Microsoft Excel"