using an array to input certain numbers in a listbox

im having trouble setting up this code, i have a file with a bunch of number in it, and its placed in my debug bin folder. i have 3 list boxes and i need to make 1 listbox have numbers 0-50, the second to have 51-75 and the third 75-100, how do i do that using an array.
scores.txt
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;

Before I could update your other question I was working on loading the ListBox's with the data. Here is that code.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    '' Linq quert 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.Item1 Into Group
                     Select New With {
                        .Grouping = Group.First().valInt.Item1,
                        .Scores = Group.Select(Function(s) s.valInt.Item2).ToArray(),
                        .Count = Group.Count
                     }).ToList()

    '' Place the values into the correct label control
    For Each g In parseData
        If g.Grouping = 1 Then
            '' Load the label with the results
            lbl0_50.Text = g.Count.ToString()
            '' Load the ListBox with the values
            lbG1.DataSource = g.Scores
        ElseIf g.Grouping = 2 Then
            lbl51_75.Text = g.Count.ToString()
            lbG2.DataSource = g.Scores
        Else
            lbl76_100.Text = g.Count.ToString()
            lbG3.DataSource = g.Scores
        End If
    Next

End Sub

'' Helper function to determin what group a score is in.
Private Function GetRange(ByVal inp As String) As Tuple(Of Integer, Integer)
    Dim itemGroup As Integer = -99
    Dim itemValue As Integer = -99
    Integer.TryParse(inp, itemValue)

    If itemValue >= 0 AndAlso itemValue <= 50 Then
        itemGroup = 1
    ElseIf itemValue >= 51 AndAlso itemValue <= 75 Then
        itemGroup = 2
    Else
        itemGroup = 3
    End If

    Return New Tuple(Of Integer, Integer)(itemGroup, itemValue)
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:
thx boss
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.