Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Help with programming code.

laajay9laajay9 Member Posts: 2
I have to create a program where a user inputs a set of quiz scores and when they press the button on my form, it will display he frequency of occurrence of each score in a histogram using asterisks and then display the mean. This is what I have so far:

Public Class Form1

Dim quizScores() As Integer
Dim maximumScore As String

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Purpose: Allows user to input the Maximum Quiz Score.
maximumScore = InputBox("Enter the Maximum Quiz Score:", "Maximum Quiz Score", , , )
ReDim quizScores(CInt(maximumScore))
End Sub

Private Sub txtmaxScore_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtmaxScore.KeyUp
'Purpose: Allows user to enter the Quiz Scores and counts the frequency of occurence of each score.
Dim score As Integer
If e.KeyCode = Keys.Enter Then
If (IsNumeric(txtmaxScore.Text)) _
AndAlso (CInt(txtmaxScore.Text)) >= 0 _
AndAlso CInt(txtmaxScore.Text) <= CInt(maximumScore) Then<br /> score = CInt(txtmaxScore.Text)
MessageBox.Show("Input must be an integer in the range 0 to " & maximumScore & "!", "ERROR!")
End If
End If
quizScores(CInt(txtmaxScore.Text)) += 1
End Sub

Private Sub btnDisplay_Click(sender As System.Object, e As System.EventArgs) Handles btnDisplay.Click
'Purpose: To display the mean of the data set and a histogram of the frequency of occurence.
Dim Total As Double = 0.0
Dim Average As Double
Dim Count As Integer
For Count = 0 To CInt(maximumScore)
Total += quizScores(CInt(txtmaxScore.Text))
Next Count
Average = Total / quizScores(CInt(txtmaxScore.Text))
Dim n As Integer = CInt("*")
For quizScores(CInt(txtmaxScore.Text)) = 0 To CInt(maximumScore)
Print(CInt(CInt(txtmaxScore.Text) & ":|" & (quizScores(n))))
Next quizScores(CInt(txtmaxScore.Text))
lstDisplay.Items.Add("Mean = " & Average)
End Sub

Private Sub btnClear_Click(sender As System.Object, e As System.EventArgs) Handles btnClear.Click
'Purpose: To clear the form.
End Sub

End Class

And I am stuck. I cannot even debug the program because I am getting a conversion to string error. Can someone help?
Sign In or Register to comment.