I've successfully managed to randomize the cards, using this code:
vb Code:
Dim Cards() As Integer
Private Sub shuffle()
Dim numberOfCards = 52
Cards = Enumerable.Repeat(0, numberOfCards ).ToArray()
Dim Tmp As Integer
Randomize()
Dim i As Integer = 0
Do While i < numberOfCards
Tmp = Int((numberOfCards + 1) * Rnd())
If Array.IndexOf(Cards, Tmp) < 0 Then
Cards(i) = Tmp
ListBox1.Items.Add(Tmp)
i += 1
End If
Loop
End Sub
This puts the numbers 1 to 52 in a litsbox randomly - which will be removed, it was simply for confiration. How would I now convert this to randomize the display of images on PictureBoxes that were added into a Panel? It's a 10x10 grid.
Also, at the minute I have them all showing red back using this code:
vb Code:
PictureBox(Row, Column).Image = Image.FromFile(path & "cards\Red.png")
PictureBox(Row, Column).SizeMode = PictureBoxSizeMode.StretchImage
So, what I am trying to do is randomize the face cards that will show upon clicking each PictureBox. I need two of each at any one time so that there's a pair.
Thanks
PMB