This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Travel project

By: a guest on May 2nd, 2013  |  syntax: None  |  size: 5.53 KB  |  views: 128  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Public Class frmTravelPlanner
  2.     Dim dailyExpensesCost(9) As Integer
  3.     Dim dailyExpensesTitles(9) As String
  4.     Dim numberOfExpenses As Integer = 0
  5.     Dim costOfExpenses As Double
  6.     Sub OutputUserInformation()
  7.         lstOutput.Items.Add("Destination: " & txtDestination.Text)
  8.         lstOutput.Items.Add("Budget: " & FormatCurrency(txtBudget.Text))
  9.         lstOutput.Items.Add("Length of Trip: " & txtLengthOfTrip.Text & " days")
  10.         lstOutput.Items.Add("accommodations: " & FormatCurrency(txtaccommodations.Text) * (txtLengthOfTrip.Text))
  11.         lstOutput.Items.Add("Food and Drink: " & FormatCurrency(txtFoodAndDrink.Text) * (txtLengthOfTrip.Text))
  12.     End Sub
  13.     Sub EditDailyExpenses(ByRef dailyExpensesCost, ByRef dailyExpensesTitle)
  14.         Dim yesOrNo As Integer
  15.         Dim clearSection As Integer = 0
  16.         For i = 0 To numberOfExpenses - 1
  17.             yesOrNo = MsgBox("Would you like to change the " & dailyExpensesTitle(i) & " expense?", MsgBoxStyle.YesNo)
  18.             If yesOrNo = vbYes Then
  19.                 lstDailyExpensesOutput.Items.RemoveAt(clearSection)
  20.                 dailyExpensesTitle(i) = InputBox("Please enter your revised expense. (i.e. gas, movies, car rental)")
  21.                 dailyExpensesCost(i) = InputBox("Please enter your revised budget for this expense.")
  22.                 lstDailyExpensesOutput.Items.Insert(clearSection, dailyExpensesTitle(i) & " " & FormatCurrency(dailyExpensesCost(i)) & "Per day; " & FormatCurrency((dailyExpensesCost(i)) * txtLengthOfTrip.Text) & " Per trip")
  23.             End If
  24.             clearSection += 1
  25.         Next
  26.     End Sub
  27.     Function TotalCostOfTravel(ByVal travelCost, ByVal costOfExpenses)
  28.         Dim costOfTrip As Double
  29.  
  30.         For i = 0 To numberOfExpenses
  31.             costOfExpenses += dailyExpensesCost(i)
  32.         Next
  33.  
  34.         costOfTrip = (costOfExpenses * txtLengthOfTrip.Text + CDbl(txtaccommodations.Text) * txtLengthOfTrip.Text + CDbl(txtFoodAndDrink.Text) * txtLengthOfTrip.Text) + travelCost
  35.         Return costOfTrip
  36.  
  37.     End Function
  38.     Sub OutputCostOfTravel(ByVal costOfTrip)
  39.         Dim difference As Double
  40.         MsgBox("Your estimated cost for the trip is " & FormatCurrency(costOfTrip) & ".")
  41.         MsgBox("Your initial budget for the trip was " & FormatCurrency(txtBudget.Text & "."))
  42.         difference = CDbl(txtBudget.Text) - costOfTrip
  43.         If difference > 0 Then
  44.             MsgBox("Your trip came in under budget and you had " & FormatCurrency(difference) & " left over.")
  45.         ElseIf difference < 0 Then
  46.             MsgBox("Your trip exceeds your initial budget by " & FormatCurrency(difference) & ". Please reveiw your budget")
  47.         ElseIf difference = 0 Then
  48.             MsgBox("Your trip is on budget with $0.00 left over.")
  49.         End If
  50.  
  51.     End Sub
  52.     Sub GetInputFromUser(ByRef dailyExpensesCost As Array, ByRef budget As Integer, ByRef lengthOfTrip As Integer,
  53.                          ByRef accommodations As Integer, ByRef foodAndDrink As Integer, ByRef numberOfExpenses As Integer, ByRef dailyExpensesTitle As Array)
  54.  
  55.         Dim stopNumber As Double
  56.         Dim stopYesOrNo As Integer
  57.         ' additional expense message box's
  58.         stopYesOrNo = MsgBox("Do you have any additional expenses you want to list here? (i.e.; Car Rental, Souvenirs, Gas, Etc.)", MsgBoxStyle.YesNo)
  59.         If stopYesOrNo = vbYes Then
  60.             Do
  61.                 dailyExpensesTitle(numberOfExpenses) = CStr(InputBox("What is your first expense? (i.e. Gas, Car Rental, Souvenirs)"))
  62.                 dailyExpensesCost(numberOfExpenses) = InputBox("What is your daily budget for that expense? (i.e. 25, 35, 45, 55)")
  63.                 numberOfExpenses += 1
  64.                 lstDailyExpensesOutput.Items.Add(dailyExpensesTitle(numberOfExpenses - 1) & " " & FormatCurrency(dailyExpensesCost(numberOfExpenses - 1)) & " Per day; " & (FormatCurrency(dailyExpensesCost(numberOfExpenses - 1) * CDbl(txtLengthOfTrip.Text))) & " For whole trip")
  65.                 stopYesOrNo = MsgBox("Are you done?", MsgBoxStyle.YesNo)
  66.                 If stopYesOrNo = vbYes Then
  67.                     stopNumber = -1
  68.                 End If
  69.  
  70.             Loop Until (stopNumber = -1 Or numberOfExpenses = 10)
  71.         End If
  72.  
  73.     End Sub
  74.     Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
  75.         Dim transportationExpense As Double = txtTravelCost.Text
  76.         Dim budget, lengthOfTrip, accommodations, foodAndDrink As Double
  77.         'clear for new entry
  78.         lstDailyExpensesOutput.Items.Clear()
  79.         lstOutput.Items.Clear()
  80.         'output
  81.         OutputUserInformation()
  82.         'input
  83.         GetInputFromUser(dailyExpensesCost, budget, lengthOfTrip, accommodations, foodAndDrink, numberOfExpenses, dailyExpensesTitles)
  84.         OutputCostOfTravel(TotalCostOfTravel(transportationExpense, costOfExpenses))
  85.         'make edit buttons visible
  86.         btnDailyExpense.Visible = True
  87.         btnRecalculate.Visible = True
  88.     End Sub
  89.     Private Sub btnDailyExpense_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDailyExpense.Click
  90.         EditDailyExpenses(dailyExpensesCost, dailyExpensesTitles)
  91.     End Sub
  92.     Private Sub btnRecalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRecalculate.Click
  93.         Dim transportationExpense As Integer = txtTravelCost.Text
  94.         OutputCostOfTravel(TotalCostOfTravel(transportationExpense, costOfExpenses))
  95.     End Sub
  96.     'programmed by alexander magoon
  97.     'cis 115
  98.  
  99. End Class
clone this paste RAW Paste Data