This is my first post, so if I'm doing something wrong, please let me know. I'm brand-spanking new to programming and I need a little help. I bought a membership to learn visual studio.net and started with the beginner series. I'm less than a third of the way through the videos and started a little programming of my own. I need help finishing it off...
Here is the code:
Code:
Public Class Form1
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim Mortgage As Double
Dim Electricity As Double
Dim gas As Double
Dim SWgas As Double
Dim Car As Double
Dim Water As Double
Dim Cable As Double
Dim Trash As Double
Dim CCB As Double
Dim Income As Double
Dim Xtra As Double
Dim Phone As Double
Dim Retire As Double
Dim Save As Double
Mortgage = Double.Parse(txtMortgage.Text)
Electricity = Double.Parse(txtElectricity.Text)
gas = Double.Parse(txtGas.Text)
SWgas = Double.Parse(txtSWgas.Text)
Car = Double.Parse(txtCar.Text)
Water = Double.Parse(txtWater.Text)
Cable = Double.Parse(txtCable.Text)
Trash = Double.Parse(txtTrash.Text)
CCB = Double.Parse(txtCCB.Text)
Income = Double.Parse(txtIncome.Text)
Xtra = Double.Parse(txtXtra.Text)
Phone = Double.Parse(txtPhone.Text)
Retire = Double.Parse(txtRetire.Text)
Save = Double.Parse(txtSave.Text)
End Sub
Function calculateIncome(ByVal Income As Double, ByVal Xtra As Double) As Double
Return Income + Xtra
End Function
Function calculateBills(ByVal Mortgage As Double, ByVal Electricity As Double, ByVal gas As Double, ByVal SWgas As Double, ByVal Car As Double, ByVal Water As Double, ByVal Cable As Double, ByVal Trash As Double, ByVal CCB As Double, ByVal Phone As Double, ByVal Retire As Double, ByVal Save As Double) As Double
Return Mortgage + Electricity + gas + SWgas + Car + Water + Cable + Trash + CCB + Phone + Retire + Save
End Function
Function calculatePlaymoney(ByVal calculateIncome As Double, ByVal calculateBills As Double)
Return calculateBills - calculateIncome
End Function
Sub displayNumbers(ByVal calculateIncome As Double, ByVal calculateBills As Double, ByVal calculatePlaymoney As Double)
txtTotalincome.Text = Format(calculateIncome.ToString(), "Currency")
txttotBills.Text = Format(calculateBills.ToString(), "Currency")
txtLeftover.Text = Format(calculatePlaymoney.ToString(), "Currency")
End Sub
End Class
I would really appreciate any help you all could provide. Not looking for gimme's, but some nudging in the right direction is/would be awesome. I've also included a screenshot of the form in case it helps...
Thanks,
Mike
Last edited by ttownfire; May 17th, 2010 at 11:46 AM.
You might do better to ask an actual question rather than just posting some code and asking us to do something with it when we don't really know what you're looking for. What exactly are you trying to do and what exactly are you having trouble with?
I'm looking to capture the the bills and total them. Also, capture the income and total it. Then subtract the two and display the result in the text boxes as labled. I'm not sure if I'm heading down the right path.
Public Class Form1
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim Mortgage As Double = Double.Parse(txtMortgage.Text)
Dim Electricity As Double = Double.Parse(txtElectricity.Text)
Dim gas As Double = Double.Parse(txtGas.Text)
Dim SWgas As Double = Double.Parse(txtSWgas.Text)
Dim Car As Double = Double.Parse(txtCar.Text)
Dim Water As Double = Double.Parse(txtWater.Text)
Dim Cable As Double = Double.Parse(txtCable.Text)
Dim Trash As Double = Double.Parse(txtTrash.Text)
Dim CCB As Double = Double.Parse(txtCCB.Text)
Dim Income As Double = Double.Parse(txtIncome.Text)
Dim Xtra As Double = Double.Parse(txtXtra.Text)
Dim Phone As Double = Double.Parse(txtPhone.Text)
Dim Retire As Double = Double.Parse(txtRetire.Text)
Dim Save As Double = Double.Parse(txtSave.Text)
Dim calcIncome As Double = calculateIncome(Income, Xtra)
Dim calcBills As Double = calculateBills(Mortgage, Electricity, gas, SWgas, Car, Water, Cable, Trash, CCB, Phone, Retire, Save)
Dim calcPlay As Double = calculatePlaymoney(calcIncome, calcBills)
displayNumbers(calcIncome, calcBills, calcPlay)
End Sub
Function calculateIncome(ByVal Income As Double, ByVal Xtra As Double) As Double
Return Income + Xtra
End Function
Function calculateBills(ByVal Mortgage As Double, ByVal Electricity As Double, ByVal gas As Double, ByVal SWgas As Double, ByVal Car As Double, ByVal Water As Double, ByVal Cable As Double, ByVal Trash As Double, ByVal CCB As Double, ByVal Phone As Double, ByVal Retire As Double, ByVal Save As Double) As Double
Return Mortgage + Electricity + gas + SWgas + Car + Water + Cable + Trash + CCB + Phone + Retire + Save
End Function
Function calculatePlaymoney(ByVal calculateIncome As Double, ByVal calculateBills As Double) As Double
Return calculateBills - calculateIncome
End Function
Sub displayNumbers(ByVal calculateIncome As Double, ByVal calculateBills As Double, ByVal calculatePlaymoney As Double)
txtTotalincome.Text = Format(calculateIncome.ToString(), "Currency")
txttotBills.Text = Format(calculateBills.ToString(), "Currency")
txtLeftover.Text = Format(calculatePlaymoney.ToString(), "Currency")
End Sub
End Class