my scores array program isn't functioning (i'm a total novice)
hi, i hope i'm posting in the right place. i'm trying to make a little program that takes several scores a user puts in, stores them in an array, then tells the user their total and averages, along with how many scores that's been counted (up to a max of 10.) it has a second function of bringing up a new window to display all the scores that have been submitted.
when i test it it is not working. i can input a value in the score text box, but it doesn't display the calculations or bring up the new window. even the exit button isn't working and i don't know why. i'm using visual studio and c#. if anyone could look this over and tell me what's wrong i'd really appreciate it! i'd posted this in code-review, but that was the wrong channel
https://pastebin.com/byz50XRe
Pastebin
score array code - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
4 Replies
have you tried to debug your code?
my suggestion would be
1) test if btnAdd_Click() method is called properly when you click the add button
2) test if scores[] has any data after btnAdd_Click() method is called
3) what
txtScore
refers to?
4) you use a lot scores.Take(scoreCount)
. What for? What do you think the difference will be between scores.Take(scoreCount).Sum();
and scores.Sum();
?
5) with the 11th number, do you get the message box?
MessageBox.Show("You cannot add more than 10 scores.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
from what i can tell, its called correctly. txtScore is for the textbox the user puts the scores in, scoreCount is meant to count how many theyve put in so far, and then its supposed to spit back the total, count, and average. this is what the form designer looks like if that helps determine the different score parts
![No description](https://cdn.answeroverflow.com/1230666726144872519/devenv_NxPWDoaEfV.png)
i still cant get it to take input, so even when i try to hit add more than ten times it doesnt show the error message ):
because your logic doesnt work
qq: how the code sees textScore textbox?
do you know how the debug in VS?
you would need to set a break point in addClick and check what each references are.