View Single Post
Old 07-02-2008, 12:03 PM   #4 (permalink)
dancswdevils
Registered User
 
Join Date: Jun 2008
Posts: 2
OS: windows xp


Re: Visual Basic 2008 - Help with Flow of program

Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

PictureBox1.Image = System.Drawing.Image.FromFile("c:\match game\cover\" & oneone & ".bmp") 'changes picturebox image from the back of a card to the front
counter = counter + 1 'Counter =0 on form_load, everytime a picturebox is clicked (there are 30 of them) counter increases by 1

If counter Mod 2 = 1 Then 'if i'm not mistaken the only 2 answers could be 1 or 0, if the answer is 1 then it means that only 1 picturebox has been clicked
temp1 = oneone 'oneone is an integer variable that holds a number from 1 to 15. Its the value of the card that is displayed in the picturebox. Each picturebox has its own variable (oneone, onetwo...) I transfered the value of oneone to temp1 so I can compare the value of the two pictureboxes that will be clicked

End If

If counter Mod 2 = 0 Then 'if this statement is true then a second picturebox has been clicked

temp2 = oneone 'transfers the value of the card shown in picturebox1 to temp2

If temp1 = temp2 Then 'if the value of the cards that were clicked are the same then run the code below
timekiller() 'I put this here or else the 2nd picturebox that the person clicks on would change to the back of the card before you get a chance to see it. It is just a loop that takes about 2 seconds to complete
turnover1(temp1, temp2, oneone, onetwo, onethree, onefour, onefive, onesix) 'these next 5 subprocedures turn the visiblity to false on the 2 pictureboxes that were clicked
turnover2(temp1, temp2, twoone, twotwo, twothree, twofour, twofive, twosix)
turnover3(temp1, temp2, threeone, threetwo, threethree, threefour, threefive, threesix)
turnover4(temp1, temp2, fourone, fourtwo, fourthree, fourfour, fourfive, foursix)
turnover5(temp1, temp2, fiveone, fivetwo, fivethree, fivefour, fivefive, fivesix)
End If

If temp1 <> temp2 Then Reset() 'if the 2 cards that were clicked do not equal then I want to turn the pictures back to a picture of the back of the deck. The reset sub procedure contains 2 porcedures 1. timekiller() and 2. backover() which goes through all the pictureboxes and changes the image to the back of the deck

End If
End Sub



When I test the program I always use picturebox2 as my 1st click and picturebox1 as my second. I added a label to see what was happening when i ran the program. I had the label display what the counter was at different stages. I put the label right under the counter=counter+1. I ran the program and clicked picturebox2 then clicked picturebox1 and the program displayed the counter result in the label after it performed the timekiller procedure (the timekiller procedure that runs if temp1<>temp2)
dancswdevils is offline   Reply With Quote