Hello,
Can someone please take a quick look at my code and let me know what I'm doing wrong.
I don't know how to return a decimal, I'm only getting whole numbers. Am I using the wrong data type?
Also, the IF Else statement is not working. It always returns "You are doing good on gas", regardless of how low the number is.
As you can tell I'm new writing my own code, but am trying to learn the basics still.
Thank you,
![]()
Public x As Integer, y As Integer, z As Integer Sub MilGal() x = InputBox("How many miles did you travel?", "Enter Miles Driven") y = InputBox("How many gallons of gasoline did you consume?", "Enter Gallons Used") Call GetMPG End Sub Sub GetMPG() z = x / y MsgBox ("Your miles per gallon is ") & z If x > 29 Then MsgBox ("You are doing good on gas!!") Else MsgBox ("You are doing bad on gas!!") End If End Sub
Bookmarks