I need help with a school assignment I am working on. I am completely lost.
Create a Visual Basic application to budget for a vacation you are planning.
In this application the user
will be able to enter eight pieces of information into text
boxes:
kilometres driven
vehicles gas mileage (litres / 100 km)
average price per litre of gasoline
number of days on vacation
average cost of meals each day
average cost for a hotel room (the
re will be one night less than the number of
days you have entered)
average daily cost of incidentals (e.g., sun tan lotion, bug spray, souvenirs)
total of all entrance fees (e.g., museums, park fees, tours).
The application displays the total cost and the
average daily cost. These values are
displayed as currency.
To calculate the cost of the vehicle travel, multiply the kilometres driven by the
mileage, divide the answer by 100, then multiply by the average price per litre of
gasoline.
The application has
two buttons: one to perform the calculation and one to clear the
text boxes and labels. The clear button will also set the focus to the first text box.
I have the form set up ok. The clear button works well but the calculate does not work at all.
Here is my code:
Public Class Form1
Dim GasMileage As String
Dim Total As String
Dim Average As String
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtKilometres.Text = ""
txtGasMileage.Text = ""
txtPriceLitre.Text = ""
lblTotalGas.Text = ""
txtVacationDays.Text = ""
txtMeals.Text = ""
txtHotel.Text = ""
txtIncidentials.Text = ""
txtEntrance.Text = ""
lblTotal.Text = ""
lblAverage.Text = ""
txtKilometres.Focus()
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
'declare variables
Dim lblTotalGas As Double
Dim dblVacationDays As Single
Dim dblMeals As Double
Dim dblHotel As Double
Dim dblIncidentials As Double
Dim dblEntrance As Double
Dim lblTotal As Double
Dim lblAverage As Double
'set variables
lblTotalGas = Val(lblTotalGas)
dblVacationDays = Val(txtVacationDays.Text)
dblMeals = Val(txtMeals.Text)
dblHotel = Val(txtHotel.Text)
dblIncidentials = Val(txtIncidentials.Text)
dblEntrance = Val(txtEntrance.Text)
lblTotal = Val(lblTotal)
lblAverage = Val(lblAverage)
lblTotal = (dblMeals + dblHotel)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnCalculate1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim dblKilometres As Double
Dim dblGasMileage As Double
Dim dblPriceLitre As Double
Dim dblTotalGas As Double
dblTotalGas = ((Val(dblKilometres) * Val(dblGasMileage) / 100 * Val(dblPriceLitre)))
End Sub
Private Sub Label11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label11.Click
End Sub
End Class
Any help would be much appreciated
Create a Visual Basic application to budget for a vacation you are planning.
In this application the user
will be able to enter eight pieces of information into text
boxes:
kilometres driven
vehicles gas mileage (litres / 100 km)
average price per litre of gasoline
number of days on vacation
average cost of meals each day
average cost for a hotel room (the
re will be one night less than the number of
days you have entered)
average daily cost of incidentals (e.g., sun tan lotion, bug spray, souvenirs)
total of all entrance fees (e.g., museums, park fees, tours).
The application displays the total cost and the
average daily cost. These values are
displayed as currency.
To calculate the cost of the vehicle travel, multiply the kilometres driven by the
mileage, divide the answer by 100, then multiply by the average price per litre of
gasoline.
The application has
two buttons: one to perform the calculation and one to clear the
text boxes and labels. The clear button will also set the focus to the first text box.
I have the form set up ok. The clear button works well but the calculate does not work at all.
Here is my code:
Public Class Form1
Dim GasMileage As String
Dim Total As String
Dim Average As String
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtKilometres.Text = ""
txtGasMileage.Text = ""
txtPriceLitre.Text = ""
lblTotalGas.Text = ""
txtVacationDays.Text = ""
txtMeals.Text = ""
txtHotel.Text = ""
txtIncidentials.Text = ""
txtEntrance.Text = ""
lblTotal.Text = ""
lblAverage.Text = ""
txtKilometres.Focus()
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
'declare variables
Dim lblTotalGas As Double
Dim dblVacationDays As Single
Dim dblMeals As Double
Dim dblHotel As Double
Dim dblIncidentials As Double
Dim dblEntrance As Double
Dim lblTotal As Double
Dim lblAverage As Double
'set variables
lblTotalGas = Val(lblTotalGas)
dblVacationDays = Val(txtVacationDays.Text)
dblMeals = Val(txtMeals.Text)
dblHotel = Val(txtHotel.Text)
dblIncidentials = Val(txtIncidentials.Text)
dblEntrance = Val(txtEntrance.Text)
lblTotal = Val(lblTotal)
lblAverage = Val(lblAverage)
lblTotal = (dblMeals + dblHotel)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnCalculate1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim dblKilometres As Double
Dim dblGasMileage As Double
Dim dblPriceLitre As Double
Dim dblTotalGas As Double
dblTotalGas = ((Val(dblKilometres) * Val(dblGasMileage) / 100 * Val(dblPriceLitre)))
End Sub
Private Sub Label11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label11.Click
End Sub
End Class
Any help would be much appreciated