array existence in VBScript

Results 1 to 3 of 3

Thread: array existence in VBScript

  1. #1
    Bérénice Mougenot Guest

    Default array existence in VBScript

    Hi! I get a &#039;subscript out of range&#039; error, because of an array which doesn&#039;t contain anything yet. However, I&#039;d like to be able to check whether it contains anything or not. How can I do that without getting an error (in VBScript)?<BR><BR>Thanks!<BR><BR>Bérénice.

  2. #2
    Join Date
    Dec 1969

    Default RE: array existence in VBScript

    I use this method :<BR><BR>dim aryTest() &#039; declare your array<BR><BR>redim aryTest(0) &#039; dimension to 1 index<BR><BR>if IsEmpty(aryTest(0)) then response.write "Nothing in this array index!"<BR><BR>If write your code wisely and the first element is empty (uninitialised) then obviously you know the array is unused.<BR><BR>Hope this helps,<BR>Mike

  3. #3
    Join Date
    Dec 1969

    Default RE: array existence in VBScript

    There are several checks you can use:<BR><BR>IsArray(YourVariable) returns True is YourVariable is an array.<BR>UBound(YourVariable) returns the upper boundary of the array YourVariable.<BR><BR>So, to see is a variable is a filled array:<BR>If IsArray(YourVariable) Then<BR> If UBound(YourVariable) &#062;= 0 Then<BR> &#039; yourVariable is a filled array!<BR> End If<BR>End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts