ensign666
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?
PSIonyx
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"
picture=int(rnd*6)+1
and
imggroup(picture).visible=true
would that work for you?
anhmytran
06-14-2001, 02:50 PM
Be careful not to use the Reserved word "Picture."
The following helps circulating your pictures (by random order)
Option Explicit
' 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
Else:
n = n + 1
End If
' Load the picture from Pic Array to the Picture Box
myPictureBox.Picture = pic(iArr(n))
End Sub
Private Sub Form_Load()
Randomize
For i = 0 To 9
iArr(i) = i
Next i
Shuffle
' Start a random number (form 0 to 9)
n = Int(Rnd * 10)
End Sub
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
Next i
End Sub
AnhMy_Tran