Control Array Error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ruckfules99
    New Member
    • Feb 2009
    • 12

    Control Array Error?

    Can someone tell me what a "Control array error" is and how to fix it?

    Heres the error i get "Control Array Element "0" Doesn't Exist" And it's with the following code:

    Code:
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If PicOpponent(Index).BorderStyle = 0 Then
        For i = 1 To 5
            PicOpponent(i).BorderStyle = 0
        Next i
        PicOpponent(Index).ZOrder
        PicOpponent(Index).Height = 1512
        PicOpponent(Index).BorderStyle = 1
    End If
    End Sub

    It highlights "If PicOpponent(Ind ex).BorderStyle = 0 Then"
  • ruckfules99
    New Member
    • Feb 2009
    • 12

    #2
    please anyone help me

    Comment

    • vdraceil
      New Member
      • Jul 2007
      • 236

      #3
      To make a control array at runtime you need to place a base control with index property=0 at design time.
      If you need to have 5 picture boxes all with the same name,you'll have to create PictureBox1 at design time with its 'index' property set to 0.Now you can load other controls by,
      For i = 1 to 5
      Load PictureBox1(i)
      PictureBox1(i). Visible = True
      Next i

      So,try setting index=0 for PicOpponent control in your form..

      Comment

      Working...