LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Can I test dynamic array for empty?

I'm reading Excel files with a Visual Basic 6.0 program. In several cases,
I'm building dynamic arrays with the elements I find. I would like an
elegant way to determing if anything has been put into my dynamic array yet.

Before the array has been ReDim-ed the first type, attempts to use LBound or
UBound give subscript out of range errors.
The debugger shows me "arrayName = Nothing" before the array is ReDim-ed.
Attempting to test arrayName = Nothing gives "Invalid Use of Object" error.
Attempting to test arrayName Is Nothing gives "Type Mismatch" error.

I've been working around this by Redimensioning the array as (0 To 0) until
the first use, then Redimensioning as (1 to 1) for the first element, (1 to
2) next, etc., but this is clunky and using 1-based subscripts isn't portable
to VB.Net, which I may do in the future. I don't know an easy way of
determining if a (0 to 0) array is empty or contains one element, without
using some dummy value.

Does anyone know a better way?
--
In theory, there is no difference between theory and practice; in practice,
there is.
 
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
How can I test if a cell is empty? Victor Delta Excel Discussion (Misc queries) 10 August 8th 07 11:22 PM
Test if the range is empty dan Excel Discussion (Misc queries) 6 December 21st 06 03:59 PM
Test for an empty selection Edward Ulle Excel Programming 4 September 8th 05 02:54 PM
Can't test for Empty objects in an array Peter Chatterton[_4_] Excel Programming 3 July 28th 05 07:06 AM
Better way to test for empty Recordset Tod Excel Programming 1 April 2nd 04 05:19 PM


All times are GMT +1. The time now is 04:01 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"