Restaurant BIll in VB2013

The program simply calculates the number of pizza slices, fries and drinks, and computes the total sales.


Source Code:
Public Class Form1
    Const PizzaPrice As Double = 1.75
    Const FriesPrice As Double = 2.0
    Const DrinksPrice As Double = 1.25
    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        Dim total As Double
        If IsNumeric(txtpizza.Text) And IsNumeric(txtfries.Text) And IsNumeric(txtdrinks.Text) Then
            total = Calculate()
            DisplayBill(total)
        Else
            MsgBox("Incorrect Input")
        End If
    End Sub

    Public Function Calculate() As Double
        Dim total As Double
        Dim pizzaqty As Integer = txtpizza.Text
        Dim friesqty As Integer = txtfries.Text
        Dim drinksqty As Integer = txtdrinks.Text
        total = (PizzaPrice * pizzaqty) + (FriesPrice * friesqty) + (DrinksPrice * drinksqty)
        Return total
    End Function

    Public Sub DisplayBill(total As Double)
        lstDisplay.Items.Add("ITEM" & vbTab & vbTab & vbTab & "QTY" & vbTab & vbTab & vbTab & "PRICE")
        lstDisplay.Items.Add("Pizza" & vbTab & vbTab & vbTab & txtpizza.Text & vbTab & vbTab & vbTab & FormatCurrency(PizzaPrice, 2))
        lstDisplay.Items.Add("Fries" & vbTab & vbTab & vbTab & txtfries.Text & vbTab & vbTab & vbTab & FormatCurrency(FriesPrice, 2))
        lstDisplay.Items.Add("Drinks" & vbTab & vbTab & vbTab & txtdrinks.Text & vbTab & vbTab & vbTab & FormatCurrency(DrinksPrice, 2))
        lstDisplay.Items.Add("")
        lstDisplay.Items.Add("TOtal Sales: " & vbTab & vbTab & vbTab & FormatCurrency(total, 2))
    End Sub
End Class

Copy and Paste this in your form.
Restaurant BIll in VB2013 Restaurant BIll in VB2013 Reviewed by code-dev on 5:50 PM Rating: 5

No comments:

Powered by Blogger.