Results 1 to 4 of 4

Thread: showing the result after comparing 2 pictures

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2021
    Posts
    2

    showing the result after comparing 2 pictures

    Hi, I am trying to make this card memory game where I have to match 2 pictures, if they are the same a message appears saying something, else something else. I am trying to compare these 2 pictures by their tags ( both have 1 as their tags) and I can't show the result

    https://gyazo.com/199de2d5ac2e47fe3d6cc2a074aa3f28
    https://gyazo.com/783eeaa55f4cef287e89451567f845ce
    https://gyazo.com/90ff6a5e18273ed193948799af1602ec

    Code:
    Public NotInheritable Class LEVEL1
    
        Private Sub LEVEL1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            ' Set the title of the form.
            Dim ApplicationTitle As String
            If My.Application.Info.Title <> "" Then
                ApplicationTitle = My.Application.Info.Title
            Else
                ApplicationTitle = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
            End If
            Me.Text = String.Format("About {0}", ApplicationTitle)
    
        End Sub
    
        Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
            Me.Close()
        End Sub
        Dim card1 As Integer
        Private Sub CARTE1_Click(sender As System.Object, e As System.EventArgs) Handles CARTE1.Click
            card1 = card1 + 1
            CARTE1.Image = Image.FromFile("C:\Users\Fabian\Desktop\facultate 2\visual basic\proiect\1DEINIMA.png")
        End Sub
    
        Dim card2 As Integer
        Private Sub CARTE2_Click(sender As System.Object, e As System.EventArgs) Handles CARTE2.Click
            card2 = card2 + 1
            CARTE2.Image = Image.FromFile("C:\Users\Fabian\Desktop\facultate 2\visual basic\proiect\1DEINIMA.png")
    
        End Sub
        Private Sub comparison()
            If CARTE1.Tag = CARTE2.Tag Then
                MsgBox("yes")
            Else
                MsgBox("no")
            End If
        End Sub
    
    End Class
    Maybe someone can help me with the code for showing the result

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,715

    Re: showing the result after comparing 2 pictures

    You are never calling your comparison method.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2021
    Posts
    2

    Re: showing the result after comparing 2 pictures

    Where do I call it ? Do I need to make a sub for it ? Because when I call it in main I get the answer before I click on the cards

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,715

    Re: showing the result after comparing 2 pictures

    If you want to get the answer when you click on the cards then it belongs in your card's Click event.

    Now you may want to add additional business logic to check if both cards have been flipped, which you can do by comparing card1 to card2:
    Code:
    card1 = card1 + 1
    CARTE1.Image = Image.FromFile("...")
    
    If (card1 = card2) Then
        comparison()
    End If
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width