Solved

Using UBound on empty array

Posted on 2004-10-13
5
4,724 Views
Last Modified: 2007-12-19
I am doing something similar to the following:

Dim myArray()
...
'Some code that may ReDim myArray to some new size
...
If UBound(myArray) > 0 Then
...


If I make it to the line that checks UBound and nothing has yet been added to the array, I get the following error:

Microsoft VBScript runtime error '800a0009'

Subscript out of range: 'UBound'

How can I find out the size of my array when there is a possibility that the array may have no values?
0
Comment
Question by:steveo225
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:Colosseo
ID: 12297798
Hi

you could try this as your first line

Dim myArray(0)

This should stop the error as the array has been dimensionalised (spelling :) )

Cheers

Scott
0
 
LVL 19

Accepted Solution

by:
peh803 earned 50 total points
ID: 12298056
Before you do ubound(myArray), do this:

if isArray(myArray) then
  if ubound(myArray)>0 then
     ''do whatever you want
  end if
else
  '' myArray isn't an array!
end if
0
 
LVL 4

Author Comment

by:steveo225
ID: 12298322
Scott, if I start the array at 0, when I try to ReDim it, I get this error:

Microsoft VBScript runtime error '800a000a'

This array is fixed or temporarily locked
0
 
LVL 4

Author Comment

by:steveo225
ID: 12298424
IsArray worked though, thanks peh
0
 
LVL 19

Expert Comment

by:peh803
ID: 12298665
glad to help!

peh803
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Update static table with two columns and multiple rows... 15 89
Summernote required 3 142
One field not displaying content (ASP Classic) 8 26
Select case on click 3 16
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question