LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Handling ubound on an uninitialised array

Rob,

I agree with you that in many cases it's preferable to work with 0
based arrays (that is with a LOWERbound of 0)

However Excel will return 1 based arrays on many of it's objects
properties

I believe that Tushar's comment re an UPPERBOUND of -1 may relate
to some functions like split/filter or a scripting dictionary's items
array which return an (0 to -1) array if no results were found.

I've just written following function which gives the DIMENSIONS of an
array. -1 for NO array, 0 for uninitialized etc. According to VBA help
vb can handle a max of 60 dimensions. (if you dont run out of memory)

Function ArrDim(vArr As Variant) As Integer
Dim i%
On Error Resume Next
If IsArray(vArr) Then
For i = 0 To 59
If IsError(LBound(vArr, i + 1)) Then Exit For
Next
Else
i = -1
End If
ArrDim = i
End Function

Once you know the dimensions you can safely test the lbound and ubound.


HTH




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Rob van Gelder wrote :

I was wondering if anyone would point that out...

In my view it's wrong to set lbound to anything other than zero - I
hinted at that with my Base 0 comment.



 
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
Why is this returning a Ubound value of zero [email protected] Excel Discussion (Misc queries) 1 September 28th 07 07:44 PM
multiple file uploading - runtime error'13': type mismatch "While Counter <= UBound(FName)" Sinner Excel Discussion (Misc queries) 3 March 1st 07 09:44 AM
UBound not in Intellisense. References problem? Stephen Rasey[_2_] Excel Programming 3 September 27th 04 12:08 AM
error handling off?? Tom Ogilvy Excel Programming 0 August 19th 04 04:31 PM
Ubound & Lbound Michael168[_80_] Excel Programming 3 June 1st 04 02:00 PM


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