Memory Game for Children


This is a typical memory game for children. You have to click the rectangles to reveal the pictures and if two of the pictures are matching they will disappear. You win the game when all the pictures are cleared and a background image is usually displayed.

In this program, I use an array of twelve  image controls and twelve picture boxes. I insert 6 pairs of images and cover them with the picture boxes.

In order to match the images, I use tags to identify them, same images are given the same tags.. The tags are being set at the images' properties windows. When two pictures boxes covering the images are being clicked, the program check for the tags of the images and if found that they are the same, then they become invisible.

The Interface


The Codes

Sub check()
'check whether the pictures are the same or not
For i = 0 To 11
If Picture1(i).Visible = False Then
For j = 0 To 11
If Picture1(j).Visible = False Then
If i <> j And Image1(i).Tag = Image1(j).Tag Then
Image1(j).Visible = False
Image1(i).Visible = False
Picture1(j).Visible = False
Picture1(i).Visible = False
End If

If i <> j And Image1(i).Tag <> Image1(j).Tag And Image1(i).Visible = True And Image1(j).Visible = True Then
Picture1(j).Visible = True
Picture1(i).Visible = True
End If

End If

Next j

End If

Next i

Timer1.Enabled = False
If Picture1(0).Visible = False _
And Picture1(1).Visible = False _
And Picture1(2).Visible = False _
And Picture1(3).Visible = False _
And Picture1(4).Visible = False _
And Picture1(5).Visible = False _
And Picture1(6).Visible = False _
And Picture1(7).Visible = False _
And Picture1(8).Visible = False _
And Picture1(9).Visible = False _
And Picture1(10).Visible = False _
And Picture1(11).Visible = False _
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "WaveAudio"
MMControl1.FileName = "D:\Liew Folder\VB program\audio\applause.wav"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
End If

End Sub

Private Sub picture1_Click(Index As Integer)
Picture1(Index).Visible = False
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
End Sub


[Back to Main Page]