문제

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

도움이 되었습니까?

해결책

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.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top