0

I am getting an error that says: Subscript out of range: '[number: 8]'

I just want to add something like this:

//if not RowArray(8) out of range then
// kill yourself at RowArray(8)
//else
// kill yourself now
//end if

The killing part is a joke :)

Thanks

4

1 回答 1

0

UBound and LBound will let you determine if a given index is a valid choice within a VBScript array.

function GetNumberEight
  If UBound(RowArray) > 8 Then
    GetNumberEight = ""
  else
    GetNumberEight = RowArray(8)
  end if
end function

If you need to specifically get one number from an array, though, you may want to consider refactoring your code. Eight variable declarations, or eight properties of a data object, will not run significantly slower than an eight member array.

(And if it's VB.NET, consider using the other .NET collection classes.)

于 2013-05-17T00:34:56.347 回答