How do i fill an array of integers from the contents of a file.

How do i  fill an array of integers from the contents of a file. (i have a debug file called  -scores.txt- that has all the exam grades in it ) and Loop through the array and count how many grades are between 0-50, 51-75, and 76-100. Then output the number of grades in each label above each listbox.

i also attached the file to this question
scores.txt.html
bob sagetAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi Bob;

The file you posted seems to be a HTML document, can you post the actual file?

Thanks
0
bob sagetAuthor Commented:
0
Fernando SotoRetiredCommented:
Hi Bob;

The sample code below should do what you are looking for.
Imports System.IO

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    '' Linq query to read the data from the file and parse them into there groups
    '' Group 1 = 0 - 50
    '' Group 2 = 51 - 75
    '' Group 3 = 76 - 100
    Dim parseData = (From valStr As String In File.ReadAllLines("C:\Working Directory\scores.txt")
                     Let valInt = GetRange(valStr)
                     Group By valInt Into Group).ToList()

    '' Place the values into the correct label control
    For Each g In parseData
        If g.valInt = 1 Then
            lbl0_50.Text = g.Group.Count.ToString()
        ElseIf g.valInt = 2 Then
            lbl51_75.Text = g.Group.Count.ToString()
        Else
            lbl76_100.Text = g.Group.Count.ToString()
        End If
    Next

End Sub

'' Helper function to determine what group a score is in.
Private Function GetRange(ByVal inp As String) As Integer
    Dim input As Integer = -99
    Integer.TryParse(inp, input)
    If input >= 0 AndAlso input <= 50 Then
        Return 1
    ElseIf input >= 51 AndAlso input <= 75 Then
        Return 2
    Else
        Return 3
    End If
End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bob sagetAuthor Commented:
you my friend are beast.!!
0
Fernando SotoRetiredCommented:
Not a problem Bob, glad to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.