15,180,027 members
See more:
Hi,
So I'm currently doing a school project where our task is to create a game.
My game is match but the number on the card represent the amount of points you earn (e.g if you get two '7's' you would earn 7 point.)

The images are currently randomized in a picture box. If there is a way you know of which can make it work please let me know... as I'm currently stuck on this problem. (also could you make you explanation easy to understand because I'm not good at coding.)

Thank
(also using Microsoft Visual Studios 2015)

What I have tried:

FlippedImage1 = null;
FlippedImage2 = null;
pic2.Enabled = false;
pic1.Enabled = false;
++FlippedCount;
ScoreCounter.Text = Convert.ToString(Convert.ToInt32(ScoreCounter.Text) + 10);
}
else
{
FlipTime.Start();
ScoreCounter.Text = Convert.ToString(Convert.ToInt32(ScoreCounter.Text) +0); //This is my current code
Posted
Updated 16-Jun-19 22:47pm

## Solution 1

Try not to write too much on one line. So instead of
ScoreCounter.Text = Convert.ToString(Convert.ToInt32(ScoreCounter.Text) + 10);

try something like:
int currentScore = Convert.ToInt32(ScoreCounter.Text);
int newScore = currentScore + 10;
string newScoreText = Convert.ToString(newScore);
ScoreCounter.Text = newScoreText;

Set a break point (F9) at the start of the calculation, hit F5 to start debugging then single step (F10/F11) line by line once your breakpoint hit. Check the values are as you expect for each line.

Once you have a specific line not having the affect you expect, then you can google that - and if still having questions ask here.

It is much easier to get help if you can say "I have line X, I expect it to do Y, but I observe Z". As it is now, we can't see what you expect the code to be doing, and that makes it hard to help you.

PS: Great you name your text box ScoreCounter - it is nice not seeing TextBox1 as we normally see from beginners!
Member 14502643 17-Jun-19 3:54am

Hi thanks for responding..
Sorry for adding so much code as i am unsure on the amount of information which is required, so thank you.

I'm still slightly confuse how to included the amount of points which you earn though

But thank you.
lmoelleb 17-Jun-19 6:58am

One of your lines appears to add 10. The other one does nothing. As we do not know where you store the number on the card, we can't tell you how to read it. Typically you would have the current card stored in a variable somewhere, in that case you can just add currentCard.Points or similar - but then you of course need to set currentCard when it becomes current. :)
Member 14502643 18-Jun-19 4:58am

Hi,
thanks for responding... had to hand up my assignment where i just didnt understand how to add it. But thank you sooooooooo much for trying to help. I decided to cut it out because i just gave up.

Thank you once again
[no name] 18-Jun-19 5:33am

yeah, this is exactly what I need
BillWoodruff 18-Jun-19 15:29pm

+5

Top Experts
Last 24hrsThis month
 M Imran Ansari 269 OriginalGriff 190 _Asif_ 95 CPallini 90 Richard Deeming 50
 OriginalGriff 4,964 Richard MacCutchan 1,783 CPallini 1,403 M Imran Ansari 1,390 Luc Pattyn 1,105

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900