Reputation: 125
I am curious below why the final msgBox is failing. I am getting both a syntax error and an end of statement error.
Option Explicit
Private Sub Travel_Expenses_Click()
Dim firstName As String
Dim lastName As String
Dim nMiles As Single
Dim milesPerGallon As Single
Dim avgPrice As Currency
Dim tripCost As Currency
firstName = InputBox("Enter your first name", "Expenses Calculator", "First")
lastName = InputBox("Enter your last name", "Expenses Calculator", "Last")
nMiles = InputBox("How many miles did you drive", "Expenses Calculator", "99")
milesPerGallon = InputBox("What was your average miles per gallon", "Expenses Calculator", "35")
avgPrice = InputBox("What was the average price per gallon on your trip", "Expenses Calculator", "1.90")
tripCost = nMiles / milesPerGallon * avgPrice
msgBox firstName & lastName & " Traveled " & nMiles & "Miles, got " & _
milesPerGallon & "Miles per Gallon on average, paid " & _
avgPrice & "per gallon on average, and paid a total of " & tripCost _
" for gas"
End Sub
Upvotes: 0
Views: 43
Reputation: 218798
You forgot the &
operator between the last two components:
tripCost _
" for gas"
should be:
tripCost & _
" for gas"
Upvotes: 5