(Solved) – Problem with List Box Order in Visual Basic

(solved)-–-problem-with-list-box-order-in-visual-basic

for some reason number 10 in my list box is showing in position 5 instead of being at the bottom. Any help is appreciated, thanks! Here’s a screenshot: https://gyazo.com/40801b2a917521eddd2baa9474cd12e4

My code:

Public Class frmMain
    Dim totalScore As Double = 0
    Dim numOfScores As Integer = 0
    Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim i As Double
        For i = 0.0 To 10.0 Step 0.5
            lstScores.Items.Add(i.ToString("0.0"))
        Next

        lstScores.SetSelected(0, True)

    End Sub

    Private Sub btnRecord_Click(sender As Object, e As EventArgs) Handles btnRecord.Click
        totalScore = totalScore   Double.Parse(lstScores.SelectedItem.ToString())

        lblTotal.Text = totalScore.ToString("0.0")

        numOfScores = numOfScores   1

        lblNumScores.Text = numOfScores.ToString

        lblAverage.Text = (totalScore / numOfScores).ToString("0.0")

    End Sub

    Private Sub btnNextSkater_Click(sender As Object, e As EventArgs) Handles btnNextSkater.Click
        totalScore = 0
        numOfScores = 0
        lblTotal.Text = ""
        lblNumScores.Text = ""
        lblAverage.Text = ""
    End Sub

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

    Private Sub lstScores_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstScores.SelectedIndexChanged
        lblTotal.Text = ""
        lblNumScores.Text = ""
        lblAverage.Text = ""
    End Sub
End Class

Leave a Reply

Your email address will not be published. Required fields are marked *