viewing paste Unknown #17588 | Text

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
Private Sub cmdBook_Click()
 
'Set up variables
Dim NumberOfNights As Integer
Dim ArrivalDate As String
Dim FamilyName As String
Dim FinalCost As Integer
Dim SingleRoom As String
Dim DoubleRoom As String
Dim FamilySuite As String
Dim SingleRoomCost As Integer
Dim DoubleRoomCost As Integer
Dim FamilySuiteCost As Integer
Dim NumSingleRoom As Integer
Dim NumDoubleRoom As Integer
Dim NumFamilySuite As Integer
Dim NumRooms As Integer
Dim OverAllCost As Integer
 
 
'Clears lists
lstRoomsBooked.Clear
lstCostOfRoom.Clear
 
 
'Gets family name and arrival date from user and assigns them to set variables
FamilyName = InputBox("Please enter your family name.")
ArrivalDate = InputBox("Please enter your desired arrival date using the DD/MM/YY format.")
 
'Do loop to get the number of nights user wishs to stay. Makes user choose a value from 1 to 14
Do
NumberOfNights = InputBox("Please enter the number of nights you wish to stay. You can stay from 1 to 14 nights.")
Loop Until NumberOfNights > 0 And NumberOfNights < 15
 
 
'Displays the Family Name, Arrival Date and Number of Nights to the interface
txtFamilyName.Text = FamilyName
txtArrivalDate.Text = ArrivalDate
txtNumberOfNights.Text = NumberOfNights
 
'Do loop to get the type of rooms the user wishes to use, forces user to rent from 1 to 4 rooms.
Do
    MsgBox "You may rent up to 4 rooms.  "
 
    NumSingleRoom = InputBox("Please enter the number of SINGLE rooms you wish to use.")
    NumDoubleRoom = InputBox("Please enter the number of DOUBLE rooms you wish to use.")
    NumFamilySuite = InputBox("Please enter the number of FAMILY SUITE rooms you wish to use.")
 
    NumRooms = NumSingleRoom + NumDoubleRoom + NumFamilySuite
Loop Until NumRooms > 0 And NumRooms < 5
 
 
'Defines the cost of a Single Room, Double Room and Family Suite
SingleRoomCost = 47
DoubleRoomCost = 90
FamilySuiteCost = 250
 
'Adds the number of single rooms to the 'RoomsBooked' list, only if there is a single room booked.
If NumSingleRoom > 0 Then
SingleRoom = NumSingleRoom & " Single Room"
lstRoomsBooked.AddItem (SingleRoom)
lstCostOfRoom.AddItem (SingleRoomCost)
Else
SingleRoom = " "
End If
 
'Adds the number of double rooms to the 'RoomsBooked' list, only if there is a double room booked.
If NumDoubleRoom > 0 Then
DoubleRoom = NumDoubleRoom & " Double Room"
lstRoomsBooked.AddItem (DoubleRoom)
lstCostOfRoom.AddItem (DoubleRoomCost)
Else
DoubleRoom = " "
End If
 
'Adds the number of family suites to the 'RoomsBooked' list, only if there is a family suite booked.
If NumFamilySuite > 0 Then
FamilySuite = NumFamilySuite & " Family Suite"
lstRoomsBooked.AddItem (FamilySuite)
lstCostOfRoom.AddItem (FamilySuiteCost)
Else
FamilySuite = " "
End If
 
 
 
'Sum to find the final cost (not overall cost)
FinalCost = ((SingleRoomCost * NumSingleRoom) + (DoubleRoomCost * NumDoubleRoom) + (FamilySuiteCost * NumFamilySuite)) * NumberOfNights
 
 
'Checks if 10% discount is available under the cirumstances, if yes, sum to take 10% then adds 20% VAT, if no, sum to add 20% VAT only. Then displays overall cost to textbox.
If NumRooms > 2 Or NumberOfNights > 6 Then
OverAllCost = FinalCost * 0.9
OverAllCost = OverAllCost * 1.2
txtFinalCost.Text = "£" & OverAllCost
Else
OverAllCost = FinalCost * 1.2
txtFinalCost.Text = "£" & OverAllCost
End If
 
 
End Sub
Viewed 581 times, submitted by Guest.