Basically for some reason when I run this problem it doesn't display the room type (which should be Studio, Moderate, Luxe, Deluxe, or Suite) and it doesn't display my daily rate or total rate. I've been sitting on this assignment for quite a few hours and I can't figure out what seems to be the issue. I think it might have something to do with my ElseIf statement or Global Constants but I'm not sure what I did wrong.
Option Explicit
Global Const Studio As Integer = 75, Moderate As Integer = 100, Luxe As
Integer = 150, Deluxe As Integer = 300, Suite As Integer = 500
Sub Charge()
Dim Tip As Double
Dim Total As Currency
Dim RmName As String
Dim RmCost As Integer
RmType = InputBox("What room type would you like? Enter '1' for Studio, '2'
for Moderate, '3' for Luxe, '4' for Deluxe, and '5' for Suite.")
If RmType < 1 Or RmType > 5 Then
MsgBox ("Incorrect Data Entry")
Exit Sub
End If
If RmType = 1 Then
RmCost = Studio And RmName = "Studio"
ElseIf RmType = 2 Then
RmCost = Moderate And RmName = "Moderate"
ElseIf RmType = 3 Then
RmCost = Luxe And RmName = "Luxe"
ElseIf RmType = 4 Then
RmCost = Deluxe And RmName = "Deluxe"
ElseIf RmType = 5 Then
RmCost = Suite And RmName = "Suite"
End If
NumDays = InputBox("How many days would you like to stay?")
Tip = InputBox("Enter in desired gratuity. For x% enter x.")
Tip = Tip / 100
Total = RmCost * NumDays * Tip
If RmType = 1 And NumDays > 2 Then
RmType = 2 And MsgBox("Studio type isn't available for more than 2
nights. You're upgraded to a Moderate option." & vbNewLine & "Room Type: " &
RmName & ". Daily rate: " & RmCost & ". Number of days: " & NumDays & ".
Total Charge: " & Total & vbCrLf & vbCrLf & "Note that the charge includes
the " & Tip * 100 & "% tip.")
Else
MsgBox ("Room Type: " & RmName & ". Daily rate: " & RmCost & ". Number of
days: " & NumDays & ". Total Charge: " & Total & vbCrLf & vbCrLf & "Note
that the charge includes the " & Tip * 100 & "% tip.")
End If
End Sub
Aucun commentaire:
Enregistrer un commentaire