Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default ReDim an Array

I have a routine that uses dynamic arrays. At certain
points in the program I need to clear out the arrays so
that they have NO elements (no UBound in other words),
just like in their virgin state.

For instance:

Option Base 1 'in declarations

Dim MyArray() As String 'a dynamic array with no UBound
ReDim MyArray(3) 'dimension for 3 elements
MyArray(1) = "Monday"
MyArray(2) = "Tuesday"
MyArray(3) = "Wednesday"

'now I want to return the array to the
'"no UBound" state like it started in.

ReDim MyArray 'compile error / syntax error
ReDim MyArray() 'compile error / syntax error
ReDim MyArray(1) 'no error, but UBound is now 1

Is there any way to do this?

Art
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default ReDim an Array

Hi Art:

Perhaps:

ReDim MyArray(0)

Regards,

Vasant.

"Art" wrote in message
...
I have a routine that uses dynamic arrays. At certain
points in the program I need to clear out the arrays so
that they have NO elements (no UBound in other words),
just like in their virgin state.

For instance:

Option Base 1 'in declarations

Dim MyArray() As String 'a dynamic array with no UBound
ReDim MyArray(3) 'dimension for 3 elements
MyArray(1) = "Monday"
MyArray(2) = "Tuesday"
MyArray(3) = "Wednesday"

'now I want to return the array to the
'"no UBound" state like it started in.

ReDim MyArray 'compile error / syntax error
ReDim MyArray() 'compile error / syntax error
ReDim MyArray(1) 'no error, but UBound is now 1

Is there any way to do this?

Art



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default ReDim an Array

Erase MyArray

--
Regards,
Tom Ogilvy

Art wrote in message
...
I have a routine that uses dynamic arrays. At certain
points in the program I need to clear out the arrays so
that they have NO elements (no UBound in other words),
just like in their virgin state.

For instance:

Option Base 1 'in declarations

Dim MyArray() As String 'a dynamic array with no UBound
ReDim MyArray(3) 'dimension for 3 elements
MyArray(1) = "Monday"
MyArray(2) = "Tuesday"
MyArray(3) = "Wednesday"

'now I want to return the array to the
'"no UBound" state like it started in.

ReDim MyArray 'compile error / syntax error
ReDim MyArray() 'compile error / syntax error
ReDim MyArray(1) 'no error, but UBound is now 1

Is there any way to do this?

Art



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Thanks Tom!


-----Original Message-----
Erase MyArray

--
Regards,
Tom Ogilvy

Art wrote in message
...
I have a routine that uses dynamic arrays. At certain
points in the program I need to clear out the arrays so
that they have NO elements (no UBound in other words),
just like in their virgin state.

For instance:

Option Base 1 'in declarations

Dim MyArray() As String 'a dynamic array with no UBound
ReDim MyArray(3) 'dimension for 3 elements
MyArray(1) = "Monday"
MyArray(2) = "Tuesday"
MyArray(3) = "Wednesday"

'now I want to return the array to the
'"no UBound" state like it started in.

ReDim MyArray 'compile error / syntax error
ReDim MyArray() 'compile error / syntax error
ReDim MyArray(1) 'no error, but UBound is now 1

Is there any way to do this?

Art



.

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
Complex conditional summing - array COUNT works, array SUM gives#VALUE fatcatfan Excel Worksheet Functions 4 November 18th 09 06:41 PM
Prevent cell/array references from changing when altering/moving thecell/array nme Excel Discussion (Misc queries) 1 September 19th 08 01:53 PM
VBA syntax help: ReDim Preserve an array Dave Excel Discussion (Misc queries) 4 September 8th 07 07:37 PM
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
Redim MyArray Peter Pantus Excel Programming 2 September 27th 03 03:37 PM


All times are GMT +1. The time now is 03:04 AM.

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"