We help IT Professionals succeed at work.

Show if Array Null / Not Null

garethtnash
garethtnash used Ask the Experts™
on
I'm a dreamweaver developer, trying to make the break...

historically I've used Recordsets with conditional statements to show or hide reggions based on recordsets / columns...

Recently I've made the move of storing the contents of the recordset in an array....

What I've not been able to work out though is ho I use Conditional statements to display or hide content based on the array...

with a recordset I would simmply write --

<% If RS.EOF And RS.BOF Then %>
Do Something
<%End if%>

To do something if the RS recordset was empty

or

<% If Not RS.EOF Or Not RS.BOF Then %>
Do Something
<%End if%>

Do something if the RS recordset is not empty

But now I'm returning the recordset data to an array named arrRs,  how do I work wih conditional statements?

Thanks Experts


GTN
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Martin Liss"There is still no cure for the common birthday." ~John Glenn
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Here's some ASP code that should help you.

Author

Commented:
So --

<% If Ubound(array_name) = -1 Then %>

And

<% IF Not Ubound(array_name) = -1 Then %>

Would that be right?
"There is still no cure for the common birthday." ~John Glenn
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
I actually don't do ASP but the answer to your question is most probably no.

The answer to your original question also depends on what you mean.

If you want to find out if a variable is an array then you would do

If IsArray(array_name) Then
    ' it's an array
Else
    ' it's not
End If

So if you have Dim array_name the above would tell you it's not an array but if you had Dim array_name() or array_name(5) it would tell you it was.

If you want to find out if there's anything in the array then you use UBound but an initialized array with nothing in it has an UBound of 0. The problem is that the same would be true of an array with something in array_name(0). So to sum up if UBound is > 0 then you know for sure there's something in the array but if UBound = 0 you probably need to look at the contents of array_name(0).

Author

Commented:
Thank you
Martin Liss"There is still no cure for the common birthday." ~John Glenn
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
ASP points, yeah! (you're welcome)