Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Exit button - closes the form
        Me.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'Calculate the tip amount.

        'INIT:
        Dim bill As Double          'Amount of bill (from textbox1)
        Dim tip As Double           'Tip amount.
        Dim total As Double         'Total to pay.

        Dim mintip As Double = 1.0 'Minimum tip.
        Dim pct As Double   'Percentage rate for tip

        'INPUT: bill
        bill = CDbl(Me.TextBox1.Text)
        sayDollars("The bill was: ", bill)

        pct = CDbl(Me.TextBox2.Text) / 100

        'PROCESS:   Calc 15%.  Check if < $1
        tip = pct * bill

        If (tip < mintip) Then
            tip = mintip
            ' (Must compute tip, before testing it.)
            ' Else
            '     say("@@@@  Begin the else-block.  tip was:   " & FormatCurrency(tip))
            '     tip = pct * bill
        End If

        total = bill + tip


        'OUTPUT:    Msg & #
        '-- Removed, in favor of say(s) --   Me.ListBox1.Items.Add("The tip should be:   " & FormatCurrency(tip))
        sayDollars("The tip should be: ", tip)
        sayDollars("The total to pay is: ", total)


    End Sub


    Sub say(ByVal s As String)
        '***** Output a string in the listbox.
        Me.LstOut.Items.Add(s)
    End Sub
    Sub sayDollars(ByVal s As String, ByVal d As Double)
        '***** Output a string in the listbox.
        Me.LstOut.Items.Add(s & FormatCurrency(d))
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LstOut.SelectedIndexChanged

    End Sub
End Class