Welcome to Dream.In.Code
Become a VB Expert!

Join 137,271 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,457 people online right now. Registration is fast and FREE... Join Now!




Trying to create a memory game

 
Reply to this topicStart new topic

Trying to create a memory game

natalie1
27 Nov, 2006 - 05:46 AM
Post #1

New D.I.C Head
*

Joined: 27 Nov, 2006
Posts: 3


My Contributions
I'm new to this so sorry if i do it wrong. I'm trying to create a memory game where press a button and this shows a label, you then press another button, if the two match then they stay on the screen. I have had various attempts at failed code including:
CODE

Public Class SpanColours
    Dim OneButton As Boolean = False
    Dim PairFound As Boolean = False
    Dim CheckColour = 0


    Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CHideButton1.Click, CHideButton2.Click, CHideButton3.Click, CHideButton4.Click, CHideButton5.Click, CHideButton6.Click, CHideButton7.Click, CHideButton8.Click, CHideButton9.Click, CHideButton10.Click, CHideButton11.Click, CHideButton12.Click
        sender.hide()
        If OneButton = True Then
            If sender.Tag = sender.Tag Then
                sender.hide()
                PairFound = True
                sender.show()
                OneButton = False
            Else
                sender.show()
                OneButton = True
            End If
        End If
    End Sub


This will make such little sense to anyone i'm sure!
Thanks if you can help me!
User is offlineProfile CardPM
+Quote Post

natalie1
RE: Trying To Create A Memory Game
27 Nov, 2006 - 07:32 AM
Post #2

New D.I.C Head
*

Joined: 27 Nov, 2006
Posts: 3


My Contributions
This might help people understand a bit more:
User presses on a button
button hide
label show
user presses on another button
button hide
label show
Compare tag values
if tag1 = tag2
show both
else hide both
Then try again
If all the labels are visible
End game

All the buttons and labels have matching tags the labels are called CBlock(and the colour i.e.Blue) and the text ones are CText(and the colour in spanish i.e. azul) The buttons that hide the label are called CHideButton1 (to 10).

Thanks x
User is offlineProfile CardPM
+Quote Post

the_hangman
RE: Trying To Create A Memory Game
27 Nov, 2006 - 07:59 AM
Post #3

D.I.C Addict
Group Icon

Joined: 18 Jan, 2006
Posts: 593



Thanked: 1 times
Dream Kudos: 200
My Contributions
I haven't tested this yet, but right off I see that you have If sender.Tag = sender.Tag .

sender.Tag will ALWAYS equal itself, thus setting off the chain of events that will hide the buttons and they will never match.

User is offlineProfile CardPM
+Quote Post

the_hangman
RE: Trying To Create A Memory Game
27 Nov, 2006 - 08:06 AM
Post #4

D.I.C Addict
Group Icon

Joined: 18 Jan, 2006
Posts: 593



Thanked: 1 times
Dream Kudos: 200
My Contributions


Also, it appears you aren't sure what "sender" is. The variable "sender" is the object that called this event. For instance if you clicked on CHideButton1, then sender would equal CHideButton1. Everytime you click a different button, sender is going to change.

so you will need to create a variable to save the first sender
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 07:48PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month