I'm trying to write a code that will calculate three products and provide a receipt. Right now the button will display a '0' instead of the 'Total Cost' that I want it to display. And nothing comes up in the (list) box that the receipt is suppose to be displayed in. Here is the code:

Public Class Form1

    Private Sub Bill_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'variables used to calculate restaurant bill
        Dim txtPizza As Double
        Dim txtFries As Double
        Dim txtDrinks As Double

        'Restaurant Bill Calculation Formula
        Dim lstReceipt As Double = (txtPizza * 1.75 + txtFries * 2 + txtDrinks * 1.25)

        'Allows Restaurant Bill to be displayed
        Me.btnCost.Text = lstReceipt.ToString

    End Sub

    Private Sub btnCost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCost.Click

        Dim txtPizza As Double
        Dim txtFries As Double
        Dim txtDrinks As Double
        Dim Bill As Double

        If txtPizza = 0 Then
            If txtPizza.Text = "" Then
                inputWrongFlagP = False
            ElseIf txtPizza = 0 Then
                MsgBox("Please enter a valid number of pieces of pizza.")
                inputWrongFlagP = True
            End If
        End If
        If txtFries = 0 Then
            If txtFries.Text = "" Then
                inputWrongFlagF = False
            ElseIf txtFries = 0 Then
                MsgBox("Please enter a valid number of pieces of fries.")
                inputWrongFlagF = True
            End If
        End If
        If txtDrinks = 0 Then
            If txtDrinks.Text = "" Then
                inputWrongFlagD = False
            ElseIf txtDrinks = 0 Then
                MsgBox("Please enter a valid number of pieces of drinks.")
                inputWrongFlagD = True
            End If
        End If

        If inputWrongFlagP = False And inputWrongFlagF = False And inputWrongFlagD = False Then
            Bill = (txtPizza * 1.75 + txtFries * 2 + txtDrinks * 1.25)

            With lstReceipt
                .BeginUpdate()
                .Items.Clear()
            End With

            Dim newItem As ListViewItem
            Dim Item As String
            Dim Quantity As Integer
            Dim Price As Double

            If txtPizza > 0 Then
                Item = "Pizza"
                Quantity = CInt(txtPizza)
                Price = Quantity * 1.75

                newItem = New ListViewItem
                With newItem
                    .Text = Item
                    .SubItems.Add(Quantity.ToString)
                    .SubItems.Add(Price.ToString("C"))
                End With

                lstReceipt.Items.Add(newItem)
            End If

            If txtFries > 0 Then
                Item = "Fries"
                Quantity = CInt(txtFries)
                Price = Quantity * 2

                newItem = New ListViewItem
                With newItem
                    .Text = Item
                    .SubItems.Add(Quantity.ToString)
                    .SubItems.Add(Price.ToString("C"))
                End With

                lstReceipt.Items.Add(newItem)
            End If

            If txtDrinks > 0 Then
                Item = "Drinks"
                Quantity = CInt(txtDrinks)
                Price = Quantity * 1.25

                newItem = New ListViewItem
                With newItem
                    .Text = Item
                    .SubItems.Add(Quantity.ToString)
                    .SubItems.Add(Price.ToString("C"))
                End With

                lstReceipt.Items.Add(newItem)
            End If


            btnCost.Text = lstReceipt.ToString

            With lstReceipt
                .EndUpdate()
            End With
        End If

    End Sub
End Class

I'm trying to write a code that will calculate three products and provide a receipt. Okay, so I've been working on it and I got the button to display the correct term and everything. But nothing still shows up in the box. Here is the code that I have now:

Public Class Bill

Private Sub btnCost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCost.Click
'variables used to calculate restaurant bill
Dim txtPizza As Double
Dim txtFries As Double
Dim txtDrinks As Double
Dim strSelect As String

strSelect = (txtPizza * 1.75 + txtFries * 2 + txtDrinks * 1.25)

'Restaurant Bill Calculation Formula
Dim lstReceipt As String = (txtPizza * 1.75 + txtFries * 2 + txtDrinks * 1.25)
End Sub

Private Sub lstReceipt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstReceipt.Click

Dim lstReceipt As String
Dim txtPizza As Double
Dim txtFries As Double
Dim txtDrinks As Double

Dim Item As String
Dim Quantity As Integer
Dim Price As Double

lstReceipt = (txtPizza * 1.75 + txtFries * 2 + txtDrinks * 1.25)

If txtPizza > 0 Then
Item = "Pizza"
Quantity = CInt(txtPizza)
Price = Quantity * 1.75
End If

If txtFries > 0 Then
Item = "Fries"
Quantity = CInt(txtFries)
Price = Quantity * 2
End If

If txtDrinks > 0 Then
Item = "Drinks"
Quantity = CInt(txtDrinks)
Price = Quantity * 1.25
End If
End Sub
End Class

This article has been dead for over six months. Start a new discussion instead.