Question Loop for checking the same image in picture box.

danter

Member
Joined
Mar 24, 2010
Messages
13
Programming Experience
Beginner
Hi Friends,

I need to write a loop which will check picture box array for the same image. If there is any should it take its value and remember it. So if there are 3 the same should give me a value of 20. That the code:
Private Sub dice()
Dim dice1, dice2, dice3, dice4, dice5, dice6 As Image
dice1 = Image.FromFile((Application.StartupPath + "\Dice1.png"))
dice2 = Image.FromFile((Application.StartupPath + "\Dice2.png"))
dice3 = Image.FromFile((Application.StartupPath + "\Dice3.png"))
dice4 = Image.FromFile((Application.StartupPath + "\Dice4.png"))
dice5 = Image.FromFile((Application.StartupPath + "\Dice5.png"))
dice6 = Image.FromFile((Application.StartupPath + "\Dice6.png"))
Dim pb() As PictureBox = {PictureBox1, PictureBox2, PictureBox3, PictureBox4, PictureBox5}
For Each p In pb
Dim ss(6) As Integer
ss(0) = 0
ss(1) = dice1.Tag = 1
ss(2) = dice2.Tag = 2
ss(3) = dice3.Tag = 3
ss(4) = dice4.Tag = 4
ss(5) = dice5.Tag = 5
ss(6) = dice6.Tag = 6
Array.Sort(ss)

For Each d In ss

If p.BorderStyle = BorderStyle.Fixed3D Then
If ss(0) = ss(1) AndAlso ss(1) = ss(2) OrElse _
ss(1) = ss(2) AndAlso ss(2) = ss(3) OrElse _
ss(2) = ss(3) AndAlso ss(3) = ss(4) Then
Label10.Text = 20
End If
End If


Next
Next
 
Back
Top