Results 1 to 10 of 10

Thread: Control array help.....[RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member psycopatchet69's Avatar
    Join Date
    Sep 2004
    Location
    Grand Rapids, MI
    Posts
    256

    Resolved Control array help.....[RESOLVED]

    [sigh] i need more help with control arrays, and cant find my answer anywhere.

    VB Code:
    1. private sub stuff
    2. dim number as integer
    3.      for number = 1 to shape1.ubound
    4.          code
    5.          code
    6.          code
    7.      next number
    8. end sub

    How would i go about setting up that code so that when the control array element doesnt exist it goes to "next number"
    Last edited by psycopatchet69; Nov 21st, 2004 at 08:31 PM.

  2. #2
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457
    You could try..

    VB Code:
    1. private sub stuff
    2. dim number as integer
    3.      for number = 1 to shape1.ubound
    4.          On Error Goto  a1
    5.          code
    6.          code
    7.          code
    8. a1:
    9.      next number
    10. end sub
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  3. #3

  4. #4

    Thread Starter
    Hyperactive Member psycopatchet69's Avatar
    Join Date
    Sep 2004
    Location
    Grand Rapids, MI
    Posts
    256
    No, that still doesnt work, David, i tried to do what you told me, martinliss, and i just dont know what youre even saying, and it didnt work....Here, ill be a little more specific with my code - try to help please.

    Oh, mousex1 and mousey1 are just the mousex and y, i have my own system of getting the mouse x and y.

    Code:
    Private Sub Back_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim number As Integer
    
    For number = 1 To Shape1.ubound
        If Mousex1 > Shape1(number).Left + 10 And Mousex1 < Shape1(number).Left + 78 Then
            If Mousey1 > Shape1(number).Top + 40 And Mousey1 < Shape1(number).Top + 98 Then
                Unload Shape1(number)
                Score = Score + 1
            End If
        End If
    Next number
    
    End Sub

  5. #5
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457
    Martin means something like this....
    VB Code:
    1. Private Sub Back_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2. Dim number As Integer
    3. Dim ctl As Shape1
    4.  
    5. For Each ctl In Shape1()
    6.      number = ctl.Index
    7.     If Mousex1 > Shape1(number).Left + 10 And Mousex1 < Shape1(number).Left + 78 Then
    8.         If Mousey1 > Shape1(number).Top + 40 And Mousey1 < Shape1(number).Top + 98 Then
    9.             Unload Shape1(number)
    10.             Score = Score + 1
    11.         End If
    12.     End If
    13. Next
    14.  
    15. End Sub
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  6. #6

    Thread Starter
    Hyperactive Member psycopatchet69's Avatar
    Join Date
    Sep 2004
    Location
    Grand Rapids, MI
    Posts
    256
    I just now tried that code, and now i get an error "User defined type not defined" in the line of "dim ctl as shape1"

  7. #7
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457
    Oops - wrong type def for Shape1. here try this
    VB Code:
    1. Private Sub Back_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2. Dim number As Integer
    3. Dim ctl As Shape
    4.  
    5. For Each ctl In Shape1()
    6.      number = ctl.Index
    7.     If Mousex1 > Shape1(number).Left + 10 And Mousex1 < Shape1(number).Left + 78 Then
    8.         If Mousey1 > Shape1(number).Top + 40 And Mousey1 < Shape1(number).Top + 98 Then
    9.             Unload Shape1(number)
    10.             Score = Score + 1
    11.         End If
    12.     End If
    13. Next
    14.  
    15. End Sub
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  8. #8
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457
    Or if that doesn't work, just use
    VB Code:
    1. Dim ctl
    and let VB sort out the types for itself.
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  9. #9

    Thread Starter
    Hyperactive Member psycopatchet69's Avatar
    Join Date
    Sep 2004
    Location
    Grand Rapids, MI
    Posts
    256
    No, it worked, and thank you, it solved my problem

  10. #10
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457
    It helps when actual code is posted. Don't forget to edit your first post and put the the tick in the message icon box for resolved
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

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