It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Simple Program using Sub routines and Functions

Moderator: dafunkymunky

Simple Program using Sub routines and Functions

Postby Inous on Tue Dec 29, 2009 2:41 am

Alright I need some direction here....


I'm making a program that displays the balance of the three items with the input of the user input quantity.

one it cost 1.75
second cost 2.00
and 3rd cost 1.25

I need to use a sub, a function and another sub , i've tried to make a program on my own but i'm quite stuck...

this is what I tried first...

Public Class frmRestaurant

Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
'Declares the variables and their value
Dim pizza, fries, drinks, As Double
GetNumbers(pizza, fries, drinks)
displayPrices(pizza, fries, drinks)

Dim fmtBill As String = "{0,-21}{1,-10}{2,-12}"
lstBill.Items.Clear()
lstBill.Items.Add(String.Format(fmtBill, "Item", "Quantity", "Prices"))
lstBill.Items.Add("")


End Sub

Sub GetNumbers(ByRef pizza As Double, ByRef fries As Double, ByRef drinks As Double)
' Gets the numbers in the txt boxes
pizza = CDbl(TxtPizza.Text)
fries = CDbl(txtFries.Text)
drinks = CDbl(txtDrinks.Text)
End Sub

Sub displayPrices(ByVal pizza As Double, ByVal fries As Double, ByVal drinks As Double)
Dim balance As Double
balance = ItemSum(pizza, fries, drinks)
lstBill.Items.Add(balance)
End Sub

Function ItemSum(ByRef num1 As Double, ByRef num2 As Double, ByRef num3 As Double)
Dim sum As Double
num1 = pizza * 1.75
num2 = fries * 2.0
num3 = drinks * 1.25
sum = num1 + num2 + num3
Return sum
End Function
End Class
Inous
 
Posts: 1
Joined: Tue Dec 29, 2009 2:20 am

Who is online

Users browsing this forum: No registered users and 3 guests