[thelist] [ASP] Empty arrays in different versions

Joshua Olson joshua at waetech.com
Tue Oct 14 20:26:56 CDT 2003


----- Original Message ----- 
From: "Peter Wakeford" <peterwakeford at intekom.co.za>
Sent: Tuesday, October 14, 2003 7:31 PM


> Josh,
> here's the official MS VB scripting documentation for it below. The
function
> should always return false if the expression contains more than one
> variable.  In the example it's a variant array (use typename() or
vartype()
> to determine)

Hiya Peter,

That's odd.  On one of my machines IsEmpty returns true if the array has no
elements in it--on the other it returns false.  I guess I go with the
documented version.  :-)

So, let's say you wanted to initialize an array using:

Dim myarray()

And then later wanted to add one element to it.  Typically I'd do something
like:

ReDim Preserve myarray(UBound(myarray) + 1)
myarray(UBound(myarray)) = "Whatever"

But, if myarray is not initalized in the first place (like before the first
call to ReDim) then UBound will fail during the ReDim.  I tried an
alternative way of trapping the error and setting it explicitely to "ReDim
myarray(0)" in the event of an error, but Err.Number was always 0... any
other options other than maintaining another variable with the length of the
array?

Thanks.

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com
706.210.0168



More information about the thelist mailing list