0% found this document useful (0 votes)
35 views2 pages

Codigo Juego Memoria Visual

This document contains the code for a memory game application written in Visual Basic. The code: 1) Randomizes the order of image tags for 16 pictureboxes on form load. 2) Handles click events for each picturebox by loading the image from the tag and tracking clicks to check for matches. 3) Uses a timer to temporarily display matched images before resetting them if they do not match. 4) Tracks the number of matches and displays a message when all 8 pairs are matched, allowing the user to restart the game.

Uploaded by

EduardoSan55
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

Codigo Juego Memoria Visual

This document contains the code for a memory game application written in Visual Basic. The code: 1) Randomizes the order of image tags for 16 pictureboxes on form load. 2) Handles click events for each picturebox by loading the image from the tag and tracking clicks to check for matches. 3) Uses a timer to temporarily display matched images before resetting them if they do not match. 4) Tracks the number of matches and displays a message when all 8 pairs are matched, allowing the user to restart the game.

Uploaded by

EduardoSan55
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Public Class Form1 Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.

Click End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For j As Integer = 0 To 7 Me.Controls.Item(j).Tag = "C:\Users\David\Desktop\imagenes memoria\" & (j + 1) & ".jpg" Me.Controls.Item(j + 8).Tag = "C:\Users\David\Desktop\imagenes memoria\" & (j + 1) & ".jpg" Next Randomize() Dim aux As String Dim a As Integer For i As Integer = 0 To 15 a = Math.Truncate(Rnd() * 16) aux = Me.Controls.Item(i).Tag Me.Controls.Item(i).Tag = Me.Controls.Item(a).Tag Me.Controls.Item(a).Tag = aux Next End Sub Dim contador As Integer = 0 Dim c As Integer = 1 Dim aux, aux2 As PictureBox Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click, PictureBox2.Click, PictureBox3.Click, PictureBox4.Click, PictureBox5.Click, PictureBox6.Click, PictureBox7.Click, PictureBox8.Click, PictureBox9.Click, PictureBox10.Click, PictureBox11.Click, PictureBox12.Click, PictureBox13.Click, PictureBox14.Click, PictureBox15.Click, PictureBox16.Click sender.image = Image.FromFile(sender.tag) If c = 1 Then aux = sender c = 2 ElseIf c = 2 Then If aux.Tag = sender.tag Then sender.enabled = False aux.Enabled = False contador += 1 If contador = 8 Then DialogResult = MessageBox.Show("Desea Jugar de nuevo?", "Gan", MessageBoxButtons.YesNo) If DialogResult = Windows.Forms.DialogResult.Yes Then Application.Restart() Else Me.Close() End If End If Else aux2 = sender TimerImagen.Start() End If c = 1 End If

End Sub Private Sub TimerImagen_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerImagen.Tick If TimerImagen.Tag = 0 Then TimerImagen.Tag += 1 Else aux2.Image = Image.FromFile("C:\Users\David\Desktop\imagenes memoria\logo.jpg") aux.Image = Image.FromFile("C:\Users\David\Desktop\imagenes memoria\logo.jpg") TimerImagen.Tag = 0 TimerImagen.Stop() End If End Sub End Class

You might also like