Using Image Arrays

selecting multiple image arrays

Page 1 of 1

3 Replies - 8499 Views - Last Post: 28 February 2008 - 08:24 PM Rate Topic: -----

#1 painkiller102  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 15
  • View blog
  • Posts: 281
  • Joined: 27-February 08

Using Image Arrays

Post icon  Posted 27 February 2008 - 08:37 PM

Ok, so what im trying to do is make a simple animation using 7 pictures (which are all arrayed from (0 through 6)) a label (used as dim or counter) and a timer. This allows the images to cycle through and create a animation. I can sucessfully achieve this without arrays, but i need to use the arrays to respawn the animation. The problem that keeps accuring is that it doesnt like me typing in image1(1,2,3,4,etc...).visible = false. The error reads "compile error: Wrong number of arguments or invalid property assignment." can anyone help me figure out how to make this code work?

Dim x As Integer
Private Sub Form_Load()
image1(0).Visible = True
image1(1).Visible = False
image1(2).Visible = False
image1(3).Visible = False
image1(4).Visible = False
image1(5).Visible = False
image1(6).Visible = False
Label1 = x
End Sub

Private Sub Timer1_Timer()
Label1 = x
If x = 1 Then
image1(1).Visible = False
image1(0, 2, 3, 4, 5, 6).Visible = False
End If
If x = 2 Then
image1(2).Visible = True
image1(0, 1, 3, 4, 5, 6).Visible = False
End If
If x = 3 Then
image1(3).Visible = True
image1(0, 1, 2, 4, 5, 6).Visible = False
End If
If x = 4 Then
image1(4).Visible = True
image1(0, 1, 2, 3, 5, 6).Visible = False
End If
If x = 5 Then
image1(5).Visible = True
image1(0, 1, 2, 3, 4, 6).Visible = False
End If
If x = 6 Then
image1(6).Visible = False
image1(0, 1, 2, 3, 4, 5).Visible = False
End If
If x = 6 Then x = 1
End Sub




Is This A Good Question/Topic? 0
  • +

Replies To: Using Image Arrays

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Using Image Arrays

Posted 27 February 2008 - 09:01 PM

You cant call an item in an array like that, it just wont work. You're going to have to do like


If x = 2 Then
    image1(2).Visible = True
    image1(0).Visible = False
    image1(1).Visible = False
    image1(3).Visible = False
    image1(4).Visible = False
    image1(5).Visible = False
    image1(6).Visible = False
End If




Also, you could do this in a loop:


Dim i As Integer
If x = 2 Then
    image1(2).Visible = True
    For i = 0 To 5
         If Not i = 2 Then
             image1(i).Visible = False
         End If
    Next
End If



That should help :)

This post has been edited by PsychoCoder: 27 February 2008 - 09:02 PM

Was This Post Helpful? 0
  • +
  • -

#3 painkiller102  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 15
  • View blog
  • Posts: 281
  • Joined: 27-February 08

Re: Using Image Arrays

Posted 28 February 2008 - 04:42 PM

Alright, thx, that answers my question ^_~
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Using Image Arrays

Posted 28 February 2008 - 08:24 PM

No problem, glad I could help. Now tell all your programming friends about us :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1