Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 





Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > The Conversation Pit > Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read

Programming A discussion forum for programs and programming used in tech-related businesses.

Reply
 
Thread Tools
Old 06-27-2008, 01:46 PM   #1 (permalink)
Registered User
 
Join Date: Jun 2008
Posts: 2
OS: windows xp


Visual Basic 2008 - Help with Flow of program

hello, below is a snippet of a program i am writing, a memory game. You click on a box to see a picture then you click on a 2nd box and see if the picture matches. The problem I am having is that on the 2nd click, the box is not displaying the picture until after all the IF THEN statements have been run. I'm pretty inexperienced so any help would be appreciated. Thanks

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

PictureBox1.Image = Image.FromFile("c:\match game\cover\" & oneone & ".bmp")
counter = counter + 1


If counter Mod 2 <> 0 Then
temp1 = oneone
firstclick = "oneone"
End If

If counter Mod 2 = 0 Then
PictureBox1.Image = Image.FromFile("c:\match game\cover\" & oneone & ".bmp")
temp2 = oneone
If temp1 = temp2 Then
timekiller()
turnover1(temp1, temp2, oneone, onetwo, onethree, onefour, onefive, onesix)
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
secondclick = "oneone"
timekiller()
backover(firstclick, secondclick)
End If
End If
End Sub
dancswdevils is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 06-28-2008, 08:47 AM   #2 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Northampton, UK
Posts: 946
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)


Re: Visual Basic 2008 - Help with Flow of program

Read next post....v

Last edited by jamiemac2005 : 06-28-2008 at 08:56 AM. Reason: This answer was junk
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 06-28-2008, 08:56 AM   #3 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Northampton, UK
Posts: 946
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)


Re: Visual Basic 2008 - Help with Flow of program

Sorry, i'm trying to work out exactly what your program is actually doing.. ignore what i just said, it's useless... If you could comment out your code (with what "oneone"'s value is) and what "counter" is initialized as (0/1) then it would help loads( i believe the problem may be in your modification of "counter"

Cheers,
Jamey
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 07-02-2008, 11:03 AM   #4 (permalink)
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  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 07-02-2008, 02:38 PM   #5 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Northampton, UK
Posts: 946
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)


Re: Visual Basic 2008 - Help with Flow of program

I can't find a problem within your code,

i have two questions though:

1) do you use the procedure PictureBox1_Click to handle all the picture boxes' click event?
2) does the timekiller event run a loop or use an interval? you'd be better to be linking the function with time so that it doesn't rely on the cpu's speed to slow the appication... I assume timekiller() should link to a "Timer" object... If you don't understand me then you'll have to google (because my knowledge of VB is not great enough to help you out.

Cheers,
Jamey
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -7. The time now is 07:55 AM.



Copyright 2001 - 2008, Tech Support Forum

Search Engine Friendly URLs by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82