Visual Basic Program

Declare a 20-element, one-dimensional integer array named intScores. Assign the following 20 numbers to the array: 88, 72, 99, 20, 66, 95, 99, 100, 72, 88, 78, 45, 57, 89, 85, 78, 75, 88, 72, and 88. The procedure should prompt the user to enter a score from 1 to 100. It then should display (in a message box) the number of students who earned that score.

I know this isn't C++, but can anyone help me with the bold part of this assignment?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

Option Explicit On
Option Strict On
Option Infer Off

Public Class frmMain

    Private strNumber As String

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub

    Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
        Dim intCount As Integer = 0
        Dim intScore As Integer
        Dim intScores() As Integer = {88, 72, 99, 20, 66, 95, 99, 100, 72, 88, 78, 45, 57, 89, 85, 78, 75, 88, 72, 88}
        strNumber = InputBox("Enter a score from 0 through 100.", "Scores")
        For Each intScore In intScores
            intCount += 1
        Next
        MsgBox(intCount)
    End Sub
End Class

You're really just missing an if then test inside of your for loop.

1
2
3
if intScore > strNumber then
  intCount = intCount + 1
end if

it ended up working with

if intScore = strNumber

Thanks for the help!
Topic archived. No new replies allowed.