Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Help with programming code.

laajay9laajay9 Posts: 2Member
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
score = CInt(txtmaxScore.Text)
lstDisplay.Items.Add(score)
Else
MessageBox.Show("Input must be an integer in the range 0 to " & maximumScore & "!", "ERROR!")
txtmaxScore.Clear()
txtmaxScore.Focus()
End If
txtmaxScore.Clear()
txtmaxScore.Focus()
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.
txtmaxScore.Clear()
lstDisplay.Items.Clear()
txtmaxScore.Focus()
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.