Results 1 to 12 of 12

Thread: Memory Game Problem

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2013
    Posts
    44

    Unhappy Memory Game Problem

    im having a terrible problem with this game, here's the flow

    upon clicking the start button, 3 pictures will pop out (2x) and after, the image back ground color will turn to indigo, (pls reffer to my codes below.)
    but the problem is it only pops out 1x and the image remains
    please help.. heres the code ...

    Code:
    Public Class logo4
    
        Private Shared timerFlag As Boolean = False
        Private Shared timerTick As Integer = 0
        Private Shared intRandomBox(15) As Integer
        Private Shared myBoxes As New List(Of System.Windows.Forms.Panel)
        Private Shared lastReplay As Boolean = False
        Private Shared intTurn As Integer = 0
        Private Shared blnLastRepeatClick As Boolean = False
        Private Shared blnGO As Boolean = False
        Private Shared FirstTurn As Boolean = True
    
        Private Sub Creation()
            Dim rn As Integer
            Dim temp As Integer = 0
    
            Do
                rn = Int(Rnd() * 16)
    
                If intRandomBox.Contains(rn) = False Then
                    intRandomBox(temp) = rn
                    temp += 1
                End If
            Loop While temp <> 15
    
            intTurn = 0
    
            myBoxes.Add(Panel1)
            myBoxes.Add(Panel2)
            myBoxes.Add(Panel3)
            myBoxes.Add(Panel4)
            myBoxes.Add(Panel5)
            myBoxes.Add(Panel6)
            myBoxes.Add(Panel7)
            myBoxes.Add(Panel8)
            myBoxes.Add(Panel9)
            myBoxes.Add(Panel10)
            myBoxes.Add(Panel11)
            myBoxes.Add(Panel12)
            myBoxes.Add(Panel13)
            myBoxes.Add(Panel14)
            myBoxes.Add(Panel15)
            myBoxes.Add(Panel16)
    
            myTimer.Interval = 250
            myTimer.Enabled = True
            myTimer.Start()
        End Sub
        Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            If FirstTurn = True Then
                Creation()
                FirstTurn = False
            End If
        End Sub
    
        Private Sub Repeat()
            myTimer.Interval = 550
            myTimer.Enabled = True
            myTimer.Start()
        End Sub
    
        Private Sub myTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myTimer.Tick
    
            Select Case timerTick
    
                Case 0
                    For counter As Integer = 0 To 15 Step 1
                        myBoxes.Item(counter).BackColor = Color.Indigo
                    Next
                    myBoxes.Item(intRandomBox(0)).BackgroundImage = My.Resources.p1
                    timerTick = timerTick + 1
                Case 1
                    myBoxes.Item(intRandomBox(1)).BackgroundImage = My.Resources.p1
                    timerTick += 1
                Case 2
                    myBoxes.Item(intRandomBox(2)).BackgroundImage = My.Resources.p1
                    timerTick += 1
    
                Case 3
                    timerTick += 1
                Case 4
                    For counter As Integer = 0 To 15 Step 1
                        myBoxes.Item(counter).BackColor = Color.Indigo
                    Next
                    timerTick = 0
    
                    If lastReplay = True Then
                        myTimer.Stop()
                        blnGO = True
                    Else
                        lastReplay = True
                    End If
    
            End Select
    
        End Sub
        Private Sub CheckIfGo(ByVal number As Integer)
            If blnGO = True Then
                MyPanel(number)
            ElseIf blnGO = False Then
                MsgBox("Lol you can't do that silly!")
            End If
        End Sub
    
        Private Sub MyPanel(ByVal number As Integer)
            Dim Panel As Object
    
            Panel = myBoxes.Item(number)
    
            If blnGO = True Then
                If intTurn = 0 And myBoxes.Item(intRandomBox(0)) Is Panel Then
                    myBoxes.Item(intRandomBox(0)).BackgroundImage = My.Resources.p1
                    intTurn = 1
                ElseIf intTurn = 1 And myBoxes.Item(intRandomBox(1)) Is Panel Then
                    myBoxes.Item(intRandomBox(1)).BackgroundImage = My.Resources.p1
                    intTurn = 2
                ElseIf intTurn = 2 And myBoxes.Item(intRandomBox(2)) Is Panel Then
                    myBoxes.Item(intRandomBox(2)).BackgroundImage = My.Resources.p1
                Else
                    If blnLastRepeatClick = False Then
                        Panel.BackColor = Color.Red
                        MsgBox("Wrong")
                        Repeat()
                        intTurn = 0
                        blnLastRepeatClick = True
                    ElseIf blnLastRepeatClick = True Then
                        MsgBox("Wrong Again, Program Closing")
                        Me.Close()
                    End If
                End If
            End If
        End Sub
    
       
    
        Private Sub CheckIfFinished()
            If myBoxes.Item(intRandomBox(2)).BackColor = Color.Yellow Then
                MsgBox("Goodjob!")
                For counter As Integer = 0 To 15 Step 1
                    myBoxes.Item(counter).BackColor = Color.Indigo
                Next
                Creation()
            End If
        End Sub
        Private Sub panel1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel1.Click
            CheckIfGo(0)
            CheckIfFinished()
        End Sub
        Private Sub Panel2_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel2.Click
            CheckIfGo(1)
            CheckIfFinished()
        End Sub
        Private Sub Panel3_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel3.Click
            CheckIfGo(2)
            CheckIfFinished()
        End Sub
        Private Sub Panel4_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel4.Click
            CheckIfGo(3)
            CheckIfFinished()
        End Sub
        Private Sub Panel5_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel5.Click
            CheckIfGo(4)
            CheckIfFinished()
        End Sub
        Private Sub Panel6_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel6.Click
            CheckIfGo(5)
            CheckIfFinished()
        End Sub
        Private Sub Panel7_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel7.Click
            CheckIfGo(6)
            CheckIfFinished()
        End Sub
        Private Sub Panel8_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel8.Click
            CheckIfGo(7)
            CheckIfFinished()
        End Sub
        Private Sub Panel9_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel9.Click
            CheckIfGo(8)
            CheckIfFinished()
        End Sub
        Private Sub Panel10_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel10.Click
            CheckIfGo(9)
            CheckIfFinished()
        End Sub
        Private Sub Panel11_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel11.Click
            CheckIfGo(10)
            CheckIfFinished()
        End Sub
        Private Sub Panel12_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel12.Click
            CheckIfGo(11)
            CheckIfFinished()
        End Sub
        Private Sub Panel13_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel13.Click
            CheckIfGo(12)
            CheckIfFinished()
        End Sub
        Private Sub Panel14_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel14.Click
            CheckIfGo(13)
            CheckIfFinished()
        End Sub
        Private Sub Panel15_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel15.Click
            CheckIfGo(14)
            CheckIfFinished()
        End Sub
        Private Sub Panel16_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel16.Click
            CheckIfGo(15)
            CheckIfFinished()
        End Sub
    
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Randomize()
        End Sub
    
    End Class

    NOTE: If i change the imagebackground=my.resources.p1 in to backcolor=color.yellow
    then the game flows perfectly, i just dont know whats the problem when i chnge it to an imagebackground.

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Memory Game Problem

    Setting the BackgroundColor to a color does not remove the BackgroundImage.
    You need to set the BackGroundImage to Nothing to clear it.
    Code:
          Case 4
            For counter As Integer = 0 To 15 Step 1
              '  myBoxes.Item(counter).BackColor = Color.Indigo   'not needed, Backcolor is already Indigo
              myBoxes.Item(counter).BackgroundImage = Nothing
            Next
    Last edited by passel; Jan 19th, 2014 at 05:37 PM.

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2013
    Posts
    44

    Re: Memory Game Problem

    Quote Originally Posted by passel View Post
    Setting the BackgroundColor to a color does not remove the BackgroundImage.
    You need to set the BackGroundImage to Nothing to clear it.
    Code:
          Case 4
            For counter As Integer = 0 To 15 Step 1
              '  myBoxes.Item(counter).BackColor = Color.Indigo   'not needed, Backcolor is already Indigo
              myBoxes.Item(counter).BackgroundImage = Nothing
            Next
    wow.. thnx it worked. but im having another problem here..

    Code:
     Private Sub CheckIfFinished()
            If myBoxes.Item(intRandomBox(2)).BackColor = Color.Yellow Then
                MsgBox("fgfggf")
                For counter As Integer = 0 To 15 Step 1
                    myBoxes.Item(counter).BackgroundImage = Nothing
                Next
                Creation()
            End If
        End Sub
    when i clicked the image correctly then msgbox("fgfggf") wont pop out,, i tried to change the backcolor=color.yellow
    into imagebackground=my.resources.p1
    but gives me an error like
    operator '=' is not defined for types 'system.type.image' and 'system.drawing.bitmap,.. what should i do?
    Last edited by winavirus_3000; Jan 19th, 2014 at 09:24 PM.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Memory Game Problem

    You can't compare images and even if you could it wouldn't help because the PictureBox stores images in a totally different format so the image in the PictureBox is literally not the image that you loaded.

    The easiest way to deal with this is to simply set a comparable property when you load the image. Tag is the most obvious choice, eg.

    vb.net Code:
    1. PictureBox1.BackgroundImage = My.Resources.ball
    2.         PictureBox1.Tag = "ball"
    3.  
    4.         If PictureBox1.Tag.ToString = "ball" Then
    5.             MsgBox("Yup!")
    6.         End If
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,043

    Re: Memory Game Problem

    I agree. The .Tag property is often overlooked as a means of tying information to a control, but that's what it's there for. It's a property of type Object, so you can put ANYTHING into it. In the case of a memory game, you might put a string or integer into the .Tag property so that you don't need to deal with what is being displayed in the picturebox at all. That way, you can separate your comparison code (which ONLY needs to deal with the contents of the .Tag property) from your display code, which can be free to do whatever you want with the picturebox without worrying about being able to compare images.
    My usual boring signature: Nothing

  6. #6

    Thread Starter
    Member
    Join Date
    Dec 2013
    Posts
    44

    Re: Memory Game Problem

    Quote Originally Posted by dunfiddlin View Post
    You can't compare images and even if you could it wouldn't help because the PictureBox stores images in a totally different format so the image in the PictureBox is literally not the image that you loaded.

    The easiest way to deal with this is to simply set a comparable property when you load the image. Tag is the most obvious choice, eg.

    vb.net Code:
    1. PictureBox1.BackgroundImage = My.Resources.ball
    2.         PictureBox1.Tag = "ball"
    3.  
    4.         If PictureBox1.Tag.ToString = "ball" Then
    5.             MsgBox("Yup!")
    6.         End If
    i tried ur code but no luck...
    i clicked on the 1st image but the msgbox pops out, supposed to be 3 images to be clicked before it pops out.. are there any codes
    for that please..

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,043

    Re: Memory Game Problem

    All Dun was showing was how you could use the .Tag property to hold a value and compare the .Tag property to something rather than trying to compare images. As far as it went, it's a good approach. You said you already had code that worked as long as you were setting the backcolor, but the code wouldn't work if you tried comparing images. What he was showing was that you could use the .Tag property rather than either the backcolor or an image. Other than that, it should integrate into your code in place of whatever image comparison you were using.

    By the way, you shouldn't be using Randomize and Rnd. In .NET, you should create a single instance of a Random object at form scope and call the .Next method on that object.
    My usual boring signature: Nothing

  8. #8

    Thread Starter
    Member
    Join Date
    Dec 2013
    Posts
    44

    Re: Memory Game Problem

    Quote Originally Posted by Shaggy Hiker View Post
    All Dun was showing was how you could use the .Tag property to hold a value and compare the .Tag property to something rather than trying to compare images. As far as it went, it's a good approach. You said you already had code that worked as long as you were setting the backcolor, but the code wouldn't work if you tried comparing images. What he was showing was that you could use the .Tag property rather than either the backcolor or an image. Other than that, it should integrate into your code in place of whatever image comparison you were using.

    By the way, you shouldn't be using Randomize and Rnd. In .NET, you should create a single instance of a Random object at form scope and call the .Next method on that object.
    ok ok.. but how will i use .Tag coz the myBoxes pertains to all panels.. and sorry im so new to vb so i cant totally understand some codes.. but i just wnt to ask if what
    code is suitable to replace the code that im pertaining..??
    can u please give me a little help... i cant seem to understand what .TAg can do and how to use it,,,...

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,043

    Re: Memory Game Problem

    .Tag is a property that can hold ANYTHING. Heck, you could put an entire control into .Tag, though I can't think of any good reason to do so. You wanted to compare the images in the picturebox, but that doesn't work so well, as you found out. Suppose that whenever you put a picture in a picturebox (or panel, or any other control of your choice), you also put something into .Tag. You could put the name of the picture into .Tag, or anything else.

    However, I just re-read what you posted and I'm not sure I'm answering your question anymore. You stated in post #3 that you tried to check the backcolor of a panel and the messagebox didn't show up. If that's the case, then .Tag isn't necessarily any part of the answer. That property is mighty useful, but you can compare backcolor properties without any issue. Comparing images is a different issue, but you said that comparing the colors themselves didn't work. If the problem you have is with the code posted in #3, then the thing to do is to put a breakpoint on the If statement and take a look at a few things. After all, this line of code:

    If myBoxes.Item(intRandomBox(2)).BackColor = Color.Yellow Then

    should work. So, if it is not working, then the most likely problem you have is that intRandomBox(2) doesn't hold what you expect it to hold. Therefore, by putting a breakpoint on that line and looking at the contents of intRandomBox(2), you will probably be surprised by the result. If that's not the question you are asking, then you'll have to ask again, as I'm clearly confused.
    My usual boring signature: Nothing

  10. #10

    Thread Starter
    Member
    Join Date
    Dec 2013
    Posts
    44

    Re: Memory Game Problem

    Quote Originally Posted by Shaggy Hiker View Post
    .Tag is a property that can hold ANYTHING. Heck, you could put an entire control into .Tag, though I can't think of any good reason to do so. You wanted to compare the images in the picturebox, but that doesn't work so well, as you found out. Suppose that whenever you put a picture in a picturebox (or panel, or any other control of your choice), you also put something into .Tag. You could put the name of the picture into .Tag, or anything else.

    However, I just re-read what you posted and I'm not sure I'm answering your question anymore. You stated in post #3 that you tried to check the backcolor of a panel and the messagebox didn't show up. If that's the case, then .Tag isn't necessarily any part of the answer. That property is mighty useful, but you can compare backcolor properties without any issue. Comparing images is a different issue, but you said that comparing the colors themselves didn't work. If the problem you have is with the code posted in #3, then the thing to do is to put a breakpoint on the If statement and take a look at a few things. After all, this line of code:

    If myBoxes.Item(intRandomBox(2)).BackColor = Color.Yellow Then

    should work. So, if it is not working, then the most likely problem you have is that intRandomBox(2) doesn't hold what you expect it to hold. Therefore, by putting a breakpoint on that line and looking at the contents of intRandomBox(2), you will probably be surprised by the result. If that's not the question you are asking, then you'll have to ask again, as I'm clearly confused.

    i was trying to attach the apllication but i cant upload it,..
    so u can download the file here http://www.mediafire.com/download/rq...plication1.rar

    pls check it..

  11. #11
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Memory Game Problem

    <edit> I was writing this before you posted. Didn't download your game, this is based on the code in the first post </edit>

    I'm not sure why you even have a call to Finish every time the person picks a panel.
    I haven't verified that any of the code works, but just looking at it, this is what appears it should be doing.
    You create an array of 16 shuffled numbers, then use the first three items from that array to select three random boxes in your 4x4 matrix that you are going to show being "lit" with an image in sequence with a interval of 550ms. You do this twice (550ms interval indicated by ..), 1..2..3..pause..clear..1..2..3..pause..clear.
    Now it is the users turn to click on the same boxes in the same order.
    It looks like you have the code set up so if they click on the correct box, in the correct order, you draw the image in the box. If they misstep on any step, 1,2,3 you display a red box, tell them they messed up, then clear the boxes (gets rid of the red and images), and show them the pattern again, two times as before (using the same code).

    The code, just looking at it, seems like that should work up to that point because you check the panel number they clicked against the panel numbers you chose randomly at the start to see if they are picking the correct box in the correct order.
    The problem that you say you are having is in the Finish code, that is checking to see if the last box has been selected (i.e. if it has the pattern showing), and you're testing that after every move.
    But, the truth is, you are already testing this case in your "bad move" code. If the number of the third panel clicked on matches the number of your third random choice, you don't set it to red, you set it to the pattern.

    Think about it. You just verified the third box was the correct box, and then you also call your CheckIfFinnished routine to test if the third box has been selected yet. But you're having problems because you're trying to test somthing you already know using a completely different method, which is giving you grief.

    Its the kind of problem, where someone is trying to write code to test something that their code is already using, in this case multiple times. as a key part of their code, that makes you wonder if perhaps they didn't write the previous part of the code, since the logic of the game kind of depends on understanding how to test for matches.

    In any case, you know this is the end of the game at the point they matched the third box so you can do your congratulations at that point, or set a "You Won" flag in that third case, which your Finish code could test. Or you could even just count the correct clicks in your "CheckIfGo" code and when you have 3 correct in a row, then the game is finished.
    Counting the correct inputs is probably not a bad way to go, if you wanted to increase the difficulty by increasing the number of boxes in the sequence once the three sequence level was completed, like the Simon game.
    Last edited by passel; Jan 22nd, 2014 at 10:35 PM.

  12. #12

    Thread Starter
    Member
    Join Date
    Dec 2013
    Posts
    44

    Re: Memory Game Problem

    Quote Originally Posted by passel View Post
    <edit> I was writing this before you posted. Didn't download your game, this is based on the code in the first post </edit>

    I'm not sure why you even have a call to Finish every time the person picks a panel.
    I haven't verified that any of the code works, but just looking at it, this is what appears it should be doing.
    You create an array of 16 shuffled numbers, then use the first three items from that array to select three random boxes in your 4x4 matrix that you are going to show being "lit" with an image in sequence with a interval of 550ms. You do this twice (550ms interval indicated by ..), 1..2..3..pause..clear..1..2..3..pause..clear.
    Now it is the users turn to click on the same boxes in the same order.
    It looks like you have the code set up so if they click on the correct box, in the correct order, you draw the image in the box. If they misstep on any step, 1,2,3 you display a red box, tell them they messed up, then clear the boxes (gets rid of the red and images), and show them the pattern again, two times as before (using the same code).

    The code, just looking at it, seems like that should work up to that point because you check the panel number they clicked against the panel numbers you chose randomly at the start to see if they are picking the correct box in the correct order.
    The problem that you say you are having is in the Finish code, that is checking to see if the last box has been selected (i.e. if it has the pattern showing), and you're testing that after every move.
    But, the truth is, you are already testing this case in your "bad move" code. If the number of the third panel clicked on matches the number of your third random choice, you don't set it to red, you set it to the pattern.

    Think about it. You just verified the third box was the correct box, and then you also call your CheckIfFinnished routine to test if the third box has been selected yet. But you're having problems because you're trying to test somthing you already know using a completely different method, which is giving you grief.

    Its the kind of problem, where someone is trying to write code to test something that their code is already using, in this case multiple times. as a key part of their code, that makes you wonder if perhaps they didn't write the previous part of the code, since the logic of the game kind of depends on understanding how to test for matches.

    In any case, you know this is the end of the game at the point they matched the third box so you can do your congratulations at that point, or set a "You Won" flag in that third case, which your Finish code could test. Or you could even just count the correct clicks in your "CheckIfGo" code and when you have 3 correct in a row, then the game is finished.
    Counting the correct inputs is probably not a bad way to go, if you wanted to increase the difficulty by increasing the number of boxes in the sequence once the three sequence level was completed, like the Simon game.

    yes yes, allmost all of what you've said are true,.. but anyways, i already figured out on how to deal with this,.. heres my code

    Code:
    Public Class logo4
    
        Private Shared timerFlag As Boolean = False
        Private Shared timerTick As Integer = 0
        Private Shared intRandomBox(15) As Integer
        Private Shared myBoxes As New List(Of System.Windows.Forms.Panel)
        Private Shared lastReplay As Boolean = False
        Private Shared intTurn As Integer = 0
        Private Shared blnLastRepeatClick As Boolean = False
        Private Shared blnGO As Boolean = False
        Private Shared FirstTurn As Boolean = True
    
        Private Sub Creation()
            Dim rn As Integer
            Dim temp As Integer = 0
    
            Do
                rn = Int(Rnd() * 16)
    
                If intRandomBox.Contains(rn) = False Then
                    intRandomBox(temp) = rn
                    temp += 1
                End If
            Loop While temp <> 15
    
            intTurn = 0
    
            myBoxes.Add(Panel1)
            myBoxes.Add(Panel2)
            myBoxes.Add(Panel3)
            myBoxes.Add(Panel4)
            myBoxes.Add(Panel5)
            myBoxes.Add(Panel6)
            myBoxes.Add(Panel7)
            myBoxes.Add(Panel8)
            myBoxes.Add(Panel9)
            myBoxes.Add(Panel10)
            myBoxes.Add(Panel11)
            myBoxes.Add(Panel12)
            myBoxes.Add(Panel13)
            myBoxes.Add(Panel14)
            myBoxes.Add(Panel15)
            myBoxes.Add(Panel16)
    
            myTimer.Interval = 250
            myTimer.Enabled = True
            myTimer.Start()
        End Sub
        Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            If FirstTurn = True Then
                Creation()
                FirstTurn = False
            End If
        End Sub
    
        Private Sub Repeat()
            myTimer.Interval = 550
            myTimer.Enabled = True
            myTimer.Start()
        End Sub
    
        Private Sub myTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myTimer.Tick
    
            Select Case timerTick
    
                Case 0
                    For counter As Integer = 0 To 15 Step 1
                        myBoxes.Item(counter).BackColor = Color.Indigo
                    Next
                    myBoxes.Item(intRandomBox(0)).Visible = False
    
                    timerTick = timerTick + 1
                Case 1
                    myBoxes.Item(intRandomBox(1)).Visible = False
    
                    timerTick += 1
                Case 2
                    myBoxes.Item(intRandomBox(2)).Visible = False
    
                    timerTick += 1
    
                Case 3
                    timerTick += 1
                Case 4
                    For counter As Integer = 0 To 15 Step 1
    
                        myBoxes.Item(counter).Visible = True
                    Next
                    timerTick = 0
    
                    If lastReplay = True Then
                        myTimer.Stop()
                        blnGO = True
                    Else
                        lastReplay = True
                    End If
    
            End Select
    
        End Sub
        Private Sub CheckIfGo(ByVal number As Integer)
            If blnGO = True Then
                MyPanel(number)
            ElseIf blnGO = False Then
                MsgBox("Lol you can't do that silly!")
            End If
        End Sub
    
        Private Sub MyPanel(ByVal number As Integer)
            Dim Panel As Object
    
            Panel = myBoxes.Item(number)
    
            If blnGO = True Then
                If intTurn = 0 And myBoxes.Item(intRandomBox(0)) Is Panel Then
                    myBoxes.Item(intRandomBox(0)).Visible = False
    
                    intTurn = 1
                ElseIf intTurn = 1 And myBoxes.Item(intRandomBox(1)) Is Panel Then
                    myBoxes.Item(intRandomBox(1)).Visible = False
    
                    intTurn = 2
                ElseIf intTurn = 2 And myBoxes.Item(intRandomBox(2)) Is Panel Then
                    myBoxes.Item(intRandomBox(2)).Visible = False
    
                Else
                    If blnLastRepeatClick = False Then
                        Panel.BackColor = Color.Red
                        MsgBox("Wrong")
                        Repeat()
                        intTurn = 0
                        blnLastRepeatClick = True
                    ElseIf blnLastRepeatClick = True Then
                        MsgBox("Wrong Again, Program Closing")
                        Me.Close()
                    End If
                End If
            End If
        End Sub
    
        Private Sub CheckIfFinished()
    
            If myBoxes.Item(intRandomBox(2)).Visible = False Then
                MsgBox("Goodjob!")
                For counter As Integer = 0 To 15 Step 1
                    myBoxes.Item(counter).Visible = False
                Next
                Creation()
            End If
        End Sub
        Private Sub panel1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel1.Click
            CheckIfGo(0)
            CheckIfFinished()
        End Sub
        Private Sub Panel2_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel2.Click
            CheckIfGo(1)
            CheckIfFinished()
        End Sub
        Private Sub Panel3_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel3.Click
            CheckIfGo(2)
            CheckIfFinished()
        End Sub
        Private Sub Panel4_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel4.Click
            CheckIfGo(3)
            CheckIfFinished()
        End Sub
        Private Sub Panel5_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel5.Click
            CheckIfGo(4)
            CheckIfFinished()
        End Sub
        Private Sub Panel6_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel6.Click
            CheckIfGo(5)
            CheckIfFinished()
        End Sub
        Private Sub Panel7_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel7.Click
            CheckIfGo(6)
            CheckIfFinished()
        End Sub
        Private Sub Panel8_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel8.Click
            CheckIfGo(7)
            CheckIfFinished()
        End Sub
        Private Sub Panel9_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel9.Click
            CheckIfGo(8)
            CheckIfFinished()
        End Sub
        Private Sub Panel10_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel10.Click
            CheckIfGo(9)
            CheckIfFinished()
        End Sub
        Private Sub Panel11_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel11.Click
            CheckIfGo(10)
            CheckIfFinished()
        End Sub
        Private Sub Panel12_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel12.Click
            CheckIfGo(11)
            CheckIfFinished()
        End Sub
        Private Sub Panel13_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel13.Click
            CheckIfGo(12)
            CheckIfFinished()
        End Sub
        Private Sub Panel14_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel14.Click
            CheckIfGo(13)
            CheckIfFinished()
        End Sub
        Private Sub Panel15_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel15.Click
            CheckIfGo(14)
            CheckIfFinished()
        End Sub
        Private Sub Panel16_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel16.Click
            CheckIfGo(15)
            CheckIfFinished()
        End Sub
    
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Randomize()
        End Sub
    
    
    End Class
    i made another 16panel that has an image at the back of the 1st 16panel with an indigo color..
    insted of placing imagebackground=my.respurces.p1 ,, what i did is to hide the 3 random panel inorder for the image to show i think u got my point here
    so when i click the 3 images upon pressing the start button, then the msgbox("Good Job") will pop out,,,... but thnx anyways guys,,,,...

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