VB6 - run-time error 9 Subscript Out of rage, Ошибка)

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by CTAPu4OK, 11 Jul 2009.

  1. CTAPu4OK

    CTAPu4OK Banned

    Joined:
    28 Oct 2008
    Messages:
    12
    Likes Received:
    0
    Reputations:
    0
    Жалуется на пред-предпоследнюю строчку
    Code:
    Public Function AddObjectWork(Reference As String, Optional Index As Integer = 0) As Integer
    	Dim Count As Integer
    	
    	AddObjectWork = Index
    	If ObjectWorkMax < Index Then
    		ObjectWorkMax = Index
    		ReDim Preserve ObjectWork(ObjectWorkMax) As ObjectsWork
    	ElseIf Index = 0 Then
    		For AddObjectWork = 1 To ObjectWorkMax
    			If ObjectWork(AddObjectWork).Reference = 0 Then Exit For
    			If AddObjectWork = ObjectWorkMax Then
    				AddObjectWork = AddObjectWork + 1
    				ObjectWorkMax = AddObjectWork
    				ReDim Preserve ObjectWork(ObjectWorkMax) As ObjectsWork
    				Exit For
    			End If
    		Next
    	End If
    	ObjectWork(AddObjectWork).Reference = GetObjectScriptIndex(Reference)
    	If ObjectScript(ObjectWork(AddObjectWork).Reference).Amountable Then ObjectWork(AddObjectWork).Amount = 1
    End Function
    Как исправить ?

    [​IMG]

    Строчка на которую жалуется
    Code:
     If ObjectScript(ObjectWork(AddObjectWork).Reference).Amountable Then ObjectWork(AddObjectWork).Amount = 1