06-11-2001, 08:43 PM
I modified an existing tic tac toe game to display a picture of my family when one of the players wins. The picture is displayed in an image control. Is there a way to make the image random, that is, every time you win a different picture pops up?
06-12-2001, 12:14 AM
I'll take a poke at it.
Why not create an image array and then call one of them
with something like "for 6 pictures"
would that work for you?
06-14-2001, 02:50 PM
Be careful not to use the Reserved word "Picture."
The following helps circulating your pictures (by random order)
' Create an array of 10 invisible Picture Boxes
' with indexes from 0 to 9. Each has its own picture.
Dim iArr(9) As Integer
Dim i As Integer, n As Integer
Private Sub Form_Click()
' Circulating pictures from 0 to 9 and 0 again
If n > 9 Then
n = 0
n = n + 1
' Load the picture from Pic Array to the Picture Box
myPictureBox.Picture = pic(iArr(n))
Private Sub Form_Load()
For i = 0 To 9
iArr(i) = i
' Start a random number (form 0 to 9)
n = Int(Rnd * 10)
Private Sub Shuffle()
Dim temp As Integer
For i = 0 To 8
n = Int(Rnd * (8 - i) + 1 + i)
temp = iArr(n)
iArr(n) = iArr(i)
iArr(i) = temp