Public Class frmRadar

Private Sub mnuClear_Click(sender As Object, e As EventArgs) Handles mnuClear.Click
    ' The mnuClear click event clears the ListBox object and hides
    ' the average speed label. It also enables the Enter Speed button

    ' Me.lstRadarSpeed1.Items.Clear()
    Me.ListBox1.Visible = False
    Me.btnEnterSpeed.Enabled = True

End Sub

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

Private Sub btnEnterSpeed_Click(sender As Object, e As EventArgs) Handles btnEnterSpeed.Click
    ' Accepts and displays up to ten speeds from the user. It
    ' then calculates and displays the average speed

    ' Variable declarations

    Dim strVehicleSpeed As String
    Dim decVehicleSpeed As Decimal
    Dim decAverageSpeed As Decimal
    Dim decTotalOfAllSpeeds As Decimal = 0D
    Dim strInputBoxMessage As String = "Enter the speed for vehicle No."
    Dim strInputBoxHeading As String = "Radar Speed"
    Dim strNormalBoxMessage As String = "Enter the speed for vehicle No."
    Dim strNonNumericErrorMessage As String = "Error - enter a number for the speed of vehicle No."
    Dim strNegativeNumberErrorMessage As String = "Error - enter a positive number for vehicle No."

    ' Declare and initialoze loop variables

    Dim strCancelButtonClicked As String = ""
    Dim intMaximumNumberOfEntries As Integer = 10
    Dim intNumberOfEntries As Integer = 1
    strVehicleSpeed = InputBox(strInputBoxMessage & intNumberOfEntries, _
    strInputBoxHeading, " ")

    ' Allows user to enter the speed of up to 10 vehiles.
    ' Ends when user has entered 10 speeds or user clicks
    ' Cancel or Close

    Do Until intNumberOfEntries > intMaximumNumberOfEntries _
     Or strVehicleSpeed = strCancelButtonClicked
        If IsNumeric(strVehicleSpeed) Then
            decVehicleSpeed = Convert.ToDecimal(strVehicleSpeed)
            If decVehicleSpeed > 0 Then
                'Me.lstRadarSpeed1.Add(decVehicleSpeed)
                decTotalOfAllSpeeds += decVehicleSpeed
                intNumberOfEntries += 1
                strInputBoxMessage = strNormalBoxMessage
            Else
                strInputBoxMessage = strNegativeNumberErrorMessage
            End If
        Else
            strInputBoxMessage = strNonNumericErrorMessage
        End If

        If intNumberOfEntries <= intMaximumNumberOfEntries Then
            strVehicleSpeed = InputBox(strInputBoxMessage & intNumberOfEntries, _
            strInputBoxHeading, " ")
        End If

    Loop
    ' Makes label visible
    Me.ListBox1.Visible = True

    'ListBox1.Sorted = True
    'Calculates and displays average speed
    If intNumberOfEntries > 1 Then
        decAverageSpeed = decTotalOfAllSpeeds / (intNumberOfEntries - 1)
        Me.ListBox1.Text = "Average speed at checkpoint is " & _
        decAverageSpeed.ToString("F1") & " mph"

    Else
        Me.ListBox1.Text = "No speed entered:"
    End If

    ' Disables the Enter Speed button
    Me.btnEnterSpeed.Enabled = False



End Sub

End Class

A TextBox displays only one item which is a string. You set the value by

TextBox1.Text = "some string value"

Or you can add to the existing text by

TextBox1.AppendText("more text")

A ListBox, however, displays a collection of items and you have to add items to that collection as in

ListBox1.Items.Add("some string value")
ListBox1.Items.Add("another string value")

so what you want is

ListBox1.Items.Add("No speed entered:")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.