Results 1 to 5 of 5

Thread: What sort of Error is this ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Location
    Lahore
    Posts
    214

    What sort of Error is this ?

    well here is the part of my code

    VB Code:
    1. Private msngMouseX()    As Single
    2. Private msngMouseY()    As Single
    3.  
    4.  
    5. Private Sub xic_MouseMove( _
    6.     Index As Integer, _
    7.     Button As Integer, _
    8.     Shift As Integer, _
    9.     x As Single, _
    10.     Y As Single _
    11. )
    12.     If (Button = vbLeftButton) Then
    13.         xic(Index).Move (xic(Index).Left + x - msngMouseX(Index)), _
    14.                            (xic(Index).Top + Y - msngMouseY(Index))
    15.  
    16.       Else
    17.         msngMouseX(Index) = x
    18.         msngMouseY(Index) = Y
    19.  
    20.     End If
    21. End Sub

    well it runs fine but at run time when i m moving instances of Xic in my workspace here and there .. after some time .. VB prompts as " run time error '9' subscript out of range " ..
    and hightlights this line in yellow

    msngMouseX(Index) = x

    what should i do to get rid of this problem

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: What sort of Error is this ?

    Add a debug.print statement in the left button statement, to get the values of everything. It should be easy to see which numbers are wrong.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Location
    Lahore
    Posts
    214

    Re: What sort of Error is this ?

    no improvement added "debug.pring" like this
    VB Code:
    1. Private Sub xic_MouseMove( _
    2.     Index As Integer, _
    3.     Button As Integer, _
    4.     Shift As Integer, _
    5.     x As Single, _
    6.     Y As Single _
    7. )
    8.     If (Button = vbLeftButton) Then
    9.         xic(Index).Move (xic(Index).Left + x - msngMouseX(Index)), _
    10.                            (xic(Index).Top + Y - msngMouseY(Index))
    11. Debug.Print
    12.       Else
    13.         msngMouseX(Index) = x
    14.         msngMouseY(Index) = Y
    15.  
    16.     End If
    17. End Sub


    ... same result ... it shows same error and after some ... u r gettin what i m trying to do i m jus dragging instance of Xic inside workspace from here and there .... what should i do

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: What sort of Error is this ?

    No, I meant something like this:

    VB Code:
    1. debug.pring xic(Index).Left & "  " & x & "  " & msngMouseX(Index))

    so you could see the values of the variables. What is the last variable?
    add another line for the Y variables.

  5. #5
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: What sort of Error is this ?

    or when the program stops click on Debug and then you can print the value of Index in the immediate window.

    How have you dimensioned msngMouseX?

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