Results 1 to 3 of 3

Thread: Subscript out of range Run time error 9

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    11

    Question Subscript out of range Run time error 9

    Hi,
    I am getting this error( Runtime Error 9 Subscript out of range) when i try to click on the button, I am using VB6.0 with SQL Server2000. I am giving the code over here, can any body help me to get out of this.. appreciate your help
    Thanks

    Public Sub cmdLvl2Click(ByVal aIndex As Integer, ByVal aiButton As Integer)

    ‘If the time Interval of the tmrCreateProcess
    'timer is set that means the task is in the que and that the finction is
    'called successively.
    If frmmain.tmrCreateProcess.Interval Then Exit Sub
    If aiButton = 2 And objNav.OperationMode = gctEditor Then
    'condition added by RL for #10320
    'If aIndex < objNav.TaskButtons.Count Then
    objNav.CurrentButtonId = objNav.TaskButtons.Item(aIndex + 1).ButtonID
    Set cobjFrmTaskOp = New cTaskOpDisplay
    cobjFrmTaskOp.Parent = Parent
    cobjFrmTaskOp.EditTaskop
    If Not (cobjFrmTaskOp Is Nothing) Then
    Set cobjFrmTaskOp = Nothing
    End If
    Call RefreshButtons
    'End If
    Else
    If aiButton = 1 And objNav.OperationMode = gctNavigator And _
    objNav.TaskButtons.Item(aIndex).TaskId <> 0 Then
    'set the global g_objmaindisplay object,
    'The object is used by the tmrCreateProcess control to execute the clicked
    'task.
    Set g_objmaindisplay = Me
    g_index = aIndex
    frmmain.tmrCreateProcess.Interval = 100
    'ExecuteBtnTask (aIndex)
    ' the above code commented ,since the same is being
    'done by the tmrCreateProcess control
    End If
    End If
    Screen.MousePointer = vbNormal
    End Sub




    I am getting the error here:
    If aiButton = 1 And objNav.OperationMode = gctNavigator And _
    objNav.TaskButtons.Item(aIndex).TaskId <> 0

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,191
    Can you please use the code tags...it is sooo hard to read the code like it is now..

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,501
    "Subscript out of range" means that you are trying to access part of an array that doesnt exist. (like if there are 10 items, you are trying to get the 20th item out of it)

    I'm tired (off to bed soon) so I havent read all of your code. I'd guess it is this though:

    objNav.TaskButtons.Item(aIndex).TaskId


    Check the value of aIndex - it is probably outside the limits of the array (nb: the first iteim in an array is usually 0, not 1 as you might expect).

Posting Permissions

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



Click Here to Expand Forum to Full Width