Jump to content
AndreiaJ

Jogo da memoria em VB

Recommended Posts

AndreiaJ

Ola !

Eu estou em um curso Tecnico de informática, onde estou com muitas dificuldades, esta muito complicado para entender linguagem de programação.

Mais agora comecei e quero ir ate o fim.

Entao o Professor passou como uma avaliaçao para fazer um jogo qualquer, e eu pensei em jogo da memória , so que ja viu os comandos nao querem dar certo, vi um modelo seu mais teria que ser na linguagem que o meu professor esta encinando entende ?

vou mostrar a vcs o que ja fiz e se vcs podem me ajudar se for possivel.

Escolhi para aparecer figuras de computadores, ainda nao coloquei o Randomize para embaralhar, mais ao clicar em 2 ele abre mesmo nao cendo o par correto .

Public Class Form1
    Dim i As Integer
    Dim tempo As Double

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Button5.Image = My.Resources.Mouse
        i = i + 1
        If i = 2 Then
            MsgBox("acertou")


            i = 0
            Button6.Visible = False 'desapare o botão
            Button5.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Button6.Image = My.Resources.Mouse
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")

            i = 0
            Button5.Visible = False
            Button6.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Image = My.Resources.Amigos
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button2.Visible = False
            Button1.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Button2.Image = My.Resources.Amigos
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button1.Visible = False
            Button2.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Button3.Image = My.Resources.Brasil1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button4.Visible = False
            Button3.Visible = False
            Tmr.Enabled = True
        End If


    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Button4.Image = My.Resources.Brasil1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button3.Visible = False
            Button4.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Button7.Image = My.Resources.Commundo1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button8.Visible = False
            Button7.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Button8.Image = My.Resources.Commundo1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button7.Visible = False
            Button8.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        Button16.Image = My.Resources.Bolacha1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button15.Visible = False
            Button16.Visible = False
            Tmr.Enabled = True
        End If

    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        Button15.Image = My.Resources.Bolacha1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button16.Visible = False
            Button15.Visible = False
            Tmr.Enabled = True
        End If

    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        Button14.Image = My.Resources.Apple1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button13.Visible = False
            Button14.Visible = False
            Tmr.Enabled = True
        End If

    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        Button13.Image = My.Resources.Apple1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button14.Visible = False
            Button13.Visible = False
            Tmr.Enabled = True
        End If

    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        Button12.Image = My.Resources.Dedo1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button11.Visible = False
            Button12.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        Button11.Image = My.Resources.Dedo1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button12.Visible = False
            Button11.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        Button10.Image = My.Resources.Teclado1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button10.Visible = False
            Button9.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Button9.Image = My.Resources.Teclado1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button9.Visible = False
            Button10.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button24.Click
        Button24.Image = My.Resources.Tecladoredondo1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button23.Visible = False
            Button24.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button23.Click
        Button23.Image = My.Resources.Tecladoredondo1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button24.Visible = False
            Button23.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button22.Click
        Button22.Image = My.Resources.Virtual
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button21.Visible = False
            Button22.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button21.Click
        Button21.Image = My.Resources.Virtual
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button22.Visible = False
            Button21.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click
        Button20.Image = My.Resources.Caneta1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button19.Visible = False
            Button20.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click
        Button19.Image = My.Resources.Caneta1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button20.Visible = False
            Button19.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
        Button18.Image = My.Resources.Portugues
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button17.Visible = False
            Button18.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        Button17.Image = My.Resources.Portugues
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button18.Visible = False
            Button17.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button32_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button32.Click
        Button32.Image = My.Resources.Reuniao
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button31.Visible = False
            Button32.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button31_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button31.Click
        Button31.Image = My.Resources.Reuniao
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button32.Visible = False
            Button31.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button30_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button30.Click
        Button30.Image = My.Resources.Mato
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button30.Visible = False
            Button29.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button29_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button29.Click
        Button29.Image = My.Resources.Mato
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button29.Visible = False
            Button30.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button28_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button28.Click
        Button28.Image = My.Resources.Melancia
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button28.Visible = False
            Button27.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button27.Click
        Button27.Image = My.Resources.Melancia
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button27.Visible = False
            Button28.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button26.Click
        Button26.Image = My.Resources.DRcomp1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button26.Visible = False
            Button25.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button25.Click
        Button25.Image = My.Resources.DRcomp1
        i = i + 1
        If i = 2 Then
            MsgBox("Acertou")
            i = 0
            Button25.Visible = False
            Button26.Visible = False
            Tmr.Enabled = True
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        i = 0
        tempo = 5
    End Sub

    Private Sub Tmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tmr.Tick
        tempo = tempo - 1
        If tempo = 0 Then
            Button1.Image = My.Resources.Sem_título ' vira botão
            Button2.Image = My.Resources.Sem_título
            Button3.Image = My.Resources.Sem_título
            Button4.Image = My.Resources.Sem_título
            Button5.Image = My.Resources.Sem_título
            Button6.Image = My.Resources.Sem_título
            Button7.Image = My.Resources.Sem_título
            Button8.Image = My.Resources.Sem_título
            Button9.Image = My.Resources.Sem_título
            Button10.Image = My.Resources.Sem_título
            Button11.Image = My.Resources.Sem_título
            Button12.Image = My.Resources.Sem_título
            Button13.Image = My.Resources.Sem_título
            Button14.Image = My.Resources.Sem_título
            Button15.Image = My.Resources.Sem_título
            Button16.Image = My.Resources.Sem_título
            Button17.Image = My.Resources.Sem_título
            Button18.Image = My.Resources.Sem_título
            Button19.Image = My.Resources.Sem_título
            Button20.Image = My.Resources.Sem_título
            Button21.Image = My.Resources.Sem_título
            Button22.Image = My.Resources.Sem_título
            Button23.Image = My.Resources.Sem_título
            Button24.Image = My.Resources.Sem_título
            Button25.Image = My.Resources.Sem_título
            Button26.Image = My.Resources.Sem_título
            Button27.Image = My.Resources.Sem_título
            Button28.Image = My.Resources.Sem_título
            Button29.Image = My.Resources.Sem_título
            Button30.Image = My.Resources.Sem_título
            Button31.Image = My.Resources.Sem_título
            Button32.Image = My.Resources.Sem_título
            Tmr.Enabled = False
        End If
    End Sub
End Class

Share this post


Link to post
Share on other sites
Andrepereira9

A opção que estas a utilizar do i = i + 1, está completamente errada.

Quando carregas no botão 5, ele mostra a imagem do Mouse e incrementa + 1 à variavel i. A variavel fica com o valor 1

Depois quando carregas no botão 1, ele mostra a imagem dos Amigos, mas incrementa + 1 à variavel i. A variavel fica com o valor 2

Por isso é que acusa sempre como certo.


A informática chegou para resolver problemas que antes não existiam

Quem ri por último é porque está conectado a 52 Kbs.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.