Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

why my VBA code does not run? Sub Renting() Dim m As Single Dim d As Single Dim price As Single Dim T As String

why my VBA code does not run?

Sub Renting()

Dim m As Single

Dim d As Single

Dim price As Single

Dim T As String

' d=days, m=milles , p= price'

m = InputBox("Enter the number of milles driven ")

T = InputBox("Enter the car type (sedan or SUV )")

d = InputBox(" enter the number of days")

If T = "SUV" And d <= 6 And m <= 80 * d Then

price = 84 * d

ElseIf T = "SUV" And d <= 6 And m > 80 * d Then

price = 84 * d + (m - d * 80) * 0.74

ElseIf T = "SUV" And d <= 29 And m <= 100 * d Then

price = 74 * d

ElseIf T = "SUV" And d <= 29 And m > 100 * d Then

price = 74 * d + (m - d * 100) * 0.64

ElseIf T = "SUV" And d >= 30 And m <= 120 * d Then

price = 64 * d

ElseIf T = "SUV" And d >= 30 And m > 120 * d Then

price = 64 * d + (m - d * 80) * 0.54

If T = "sedan" And d <= 6 And m <= 80 * d Then

price = 79 * d

ElseIf T = "sedan" And d <= 6 And m > 80 * d Then

price = 79 * d + ((m - d * 80) * 0.69)

ElseIf T = "sedan" And d <= 29 And m <= 100 * d Then

price = 69 * d

ElseIf T = "sedan" And d <= 29 And m > 100 * d Then

price = 69 * d + ((m - d * 100) * 0.59)

ElseIf T = "sedan" And d >= 30 And m <= 120 * d Then

price = 59 * d

ElseIf T = "sedan" And d >= 30 And m > 120 * d Then

price = 59 * d + ((m - d * 120) * 0.49)

End If

End If

MsgBox " Your total price is: " & Application.Round(price, 1)

End Sub

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions