I am programming an application in VB that allows the user to input test scores and then it automatically calculates the average, high score, low score, and a grade distribution (A, B, C, D, F) for the entire class. I have the average, high score, and the distribution working for the most part. However, I am struggling with the low score. The high score works perfectly fine but by using the same logic to get the low score, it usually will leave the low score text box either blank or as "0" once I convert it back from an integer to a string. Also, my grade distribution label is a bit wacky. My instructor requested that we create one label for all letter grades and use concatenation to tie multiple strings together. For the most part, it works, but the problem I'm having is it's delayed. For instance, the first time I enter a number, it doesn't assign the grade to any letter grade value, but when I input a second score, it tracks it perfectly fine. The same applies to entering another score that would fall within a different letter grade category (e.g. 88 is counted as a "B" but then if I enter 70, for instance, immediately afterwards, it still tracks it as a B and will only be corrected after I enter another score.) Sorry for typing so much, I hope this is somewhat coherent. Thanks in advance for any advice, I'm new to VB.
By the way, just noticed that my low score code is completely off. I know, I know. It's essentially stating that any number less than or equal to 100 is the low score, which is obviously not what I am looking for. I just put that there temporarily because I was tired of seeing "0" or nothing. My original low score code looked like this:
Dim highInteger As Integer Dim lowInteger As Integer Dim enteredInteger As Integer Dim countA As Integer Dim countB As Integer Dim countC As Integer Dim countD As Integer Dim countF As Integer 'High and Low Score Code If enteredInteger > highInteger Then highInteger = enteredInteger highTextBox.Text = highInteger.ToString() End If If enteredInteger <= 100 Then lowInteger = enteredInteger lowTextBox.Text = lowInteger.ToString() End If 'Grade Distribution Label Code gradesLabel.Text = "A's" & " " & countA.ToString() & " " & " " & "B's" & " " & countB.ToString() & " " & " " & "C's" & " " & countC.ToString() & " " & " " & "D's" & " " & countD.ToString() & " " & " " & "F's" & countF.ToString() If enterButton.Enabled = True Then End If If enteredInteger >= 90 Then countA = countA + 1 Else If enteredInteger >= 80 And enteredInteger < 90 Then countB = countB + 1 Else If enteredInteger >= 70 And enteredInteger < 80 Then countC = countC + 1 Else If enteredInteger >= 60 And enteredInteger < 70 Then countD = countD + 1 Else countF = countF + 1 End If End If End If End If
By the way, just noticed that my low score code is completely off. I know, I know. It's essentially stating that any number less than or equal to 100 is the low score, which is obviously not what I am looking for. I just put that there temporarily because I was tired of seeing "0" or nothing. My original low score code looked like this:
If enteredInteger < lowInteger Then lowInteger = enteredInteger lowTextBox.Text = lowInteger.ToString()