Problem with solving Equation
Problem with solving Equation
Problem with solving Equation
Problem with solving Equation
Problem with solving Equation
Problem with solving Equation Problem with solving Equation Problem with solving Equation Problem with solving Equation Problem with solving Equation Problem with solving Equation Problem with solving Equation Problem with solving Equation
Problem with solving Equation Problem with solving Equation
Problem with solving Equation
Go Back  Xtreme Visual Basic Talk > > > Problem with solving Equation


Reply
 
Thread Tools Display Modes
  #1  
Old 03-31-2010, 05:59 PM
Hasimar Hasimar is offline
Newcomer
 
Join Date: Mar 2010
Posts: 9
Default Problem with solving Equation


Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
Dim Pizza, Fries, Drinks As Double 'These variables are assigned to text boxes
Dim PizzaPrice, FriesPrice, DrinksPrice As Double
'These variables are assigned to the quantity



PizzaPrice = 1.75
FriesPrice = 2.0 'The prices of the items
DrinksPrice = 1.25





Subquanity(Pizza, Fries, Drinks)
'assigns the varables to the sub procedure

DisplayTotal(Pizza, Fries, Drinks, PizzaPrice, FriesPrice, DrinksPrice)







End Sub


Sub Subquanity(ByVal pizza As Double, ByVal Fries As Double, ByVal Drinks As Double)








pizza = CDbl(txtPizza.Text)
Fries = CDbl(txtFries.Text) 'Assigns what number you type for the Quanity in each txt box
Drinks = CDbl(txtDrinks.Text)




End Sub
Sub displaytotal(ByVal pizza As Double, ByVal fries As Double, ByVal drinks As Double, _
ByVal pizzaprice As Double, ByVal friesprice As Double, ByVal drinksprice As Double)
Dim total As Double

total = Math(pizza, fries, drinks, pizzaprice, friesprice, drinksprice)


Dim fmtdouble As String = "{0, -6} {1, 40} {2, 45}"
'formats the lst box

lstResults.Items.Clear()
lstResults.Items.Add(String.Format(fmtdouble, "Item", "Quantity", "Price"))
lstResults.Items.Add(String.Format(fmtdouble, "Total", " ", FormatCurrency(total)))



End Sub

Function Math(ByVal pizza As Double, ByVal fries As Double, ByVal drinks As Double, ByVal pizzaPrice As Double, ByVal friesprice As Double, ByVal drinksprice As Double) As Double




Return (pizza * pizzaPrice) + (fries * friesprice) + (drinks * drinksprice) 'This code should come out to $19.50 when i press my button. But it displays $0.00 in my list box

Reply With Quote
  #2  
Old 03-31-2010, 07:31 PM
Rockoon's Avatar
Rockoon Rockoon is offline
Joseph Koss

* Guru *
 
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
Default

Quote:
Sub Subquanity(ByVal pizza As Double, ByVal Fries As Double, ByVal Drinks As Double)
Because these are ByVal, the caller of this procedure will not receive the updated values. You need to change them to ByRef.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Problem with solving Equation
Problem with solving Equation
Problem with solving Equation Problem with solving Equation
Problem with solving Equation
Problem with solving Equation
Problem with solving Equation Problem with solving Equation Problem with solving Equation Problem with solving Equation Problem with solving Equation Problem with solving Equation Problem with solving Equation
Problem with solving Equation
Problem with solving Equation
 
Problem with solving Equation
Problem with solving Equation
 
-->