0% found this document useful (0 votes)
6 views

Assignment 3

Uploaded by

garrethmametja
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Assignment 3

Uploaded by

garrethmametja
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment 3 CSIS1683

DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS


CSIS1683 ASSIGNMENT 3 3 SEPTEMBER 2024
TOTAL [70]
INSTRUCTIONS
1. This is an individual assignment. Students are not allowed to work together, use copied code from the internet
or use any AI-generated code. All work submitted must be your own!
2. Answer all the questions.
3. Save your work often.
4. Make use of indentation in the instances where you write VBA code.
5. Keep a copy of this assignment until the end of the semester.
6. Marks will be subtracted for:
6.1 Omitting your Student Number, Initials and Surname as comments at the top of each code module.
6.2 Not properly indenting the code.
6.3 Omitting Option Explicit.
6.4 Not renaming the file correctly.

INTRODUCTION
In this assignment, you will be creating a small system that a costume rental company can use. Costumes-
R-Us rents out different types of clown costumes. The system will allow a person to pick a clown costume
to rent. The total rental fee will be calculated by considering the following:
• The type of clown costume that was rented;
• The number of days that the clown costume was rented;
• If the clown costume had to be delivered to the customer;
• If the clown costume was damaged.

QUESTION 1
Create a new Excel workbook and save it as an Excel Macro-Enabled Workbook (*.xlsm). Select this option
from the Save as type drop-down list in the Save As window. The filename should be
A3_Studentnumber_Initials_Surname.xlsm (e.g. A3_123456_W_Nel.xlsm). When working in the
computer labs, ensure that you save your work on your Flash Drive. Save at least every 5 minutes.

QUESTION 2 [4 MARKS]
Recreate the content of the figure below. Ensure that the content is in the correct cells. Add the AutoSum
Function to B18, which will sum B15:B17. Change the number format of B15:B18 to Currency.

1 of 5 UFS
Assignment 3 CSIS1683

QUESTION 3
Create a code module named SelectCostume. Write the code for questions 3.1 – 3.4 in this code module.
[1 MARK]

3.1 Create a Sub Procedure named Start. [17 MARKS]


• This Sub Procedure must ensure that Sheet1 is active.
• This Sub Procedure must display the following to the user:

• The options A, B and C must be read from the cells E2:E4 and then displayed to the user as part
of the prompt. Declare three variables (the options), assign the values E2:E4 to them, and then
use them as part of the prompt for the user.
• The user’s input must be converted to uppercase when the OK button is clicked, and then it
should assigned to a variable.
• The user’s input must be checked by comparing the declared variables (A, B and C) with the
user’s input (make use of an If…Then…Else). When the user enters either an A, B or C, the
following should happen:
o The value that the user entered must be displayed in B2.
o The CostumeDescription Sub Procedure must be called (see Question 3.2).
o The RentalDetails Sub Procedure must be called (see Question 3.3).
o The CostumeConditionBefore Sub Procedure must be called (see Question 3.4).

2 of 5 UFS
Assignment 3 CSIS1683

When the user enters any other value, the following Message box must be displayed, and once
the OK button is clicked, the code execution should stop:

• Add a button on the worksheet named “Estimation” that will call this Sub Procedure when
clicked. Refer to the example image at the end.

3.2 Create a Sub Procedure named CostumeDescription. [6 MARKS]


• This Sub Procedure must not be accessible to other code modules.
• This Sub Procedure must receive the user-entered value A, B, or C (see Question 3.1) and then
write the name of the corresponding costume into B3. DO NOT hardcode the costume names
but rather read them from the corresponding cells (F2:F4). Make use of a Select…Case to
determine which costume name to write to the cell.

3.3 Create a Sub Procedure named RentalDetails. [3 MARKS]


• This Sub Procedure must not be accessible to other code modules.
• This Sub Procedure should display the following two Input boxes and write the user-entered
values to B6 and B7, respectively (Do not make use of variables. Assign the user input directly to
the respective cells):

3.4 Create a Sub Procedure named CostumeConditionBefore. [4 MARKS]


• This Sub Procedure must not be accessible to other code modules.
• This Sub Procedure should display the following and write the user’s entered value in B10.

3 of 5 UFS
Assignment 3 CSIS1683

The value “3” in the prompt should not be hardcoded but rather be calculated by counting the
number of costume conditions in E7:E9. Use the CountA function. Refer to
https://www.automateexcel.com/vba/vba-count/ for an example. Note: The user will enter the
numbers 1, 2 or 3.

QUESTION 4
Create a code module named ReturnCostume. Write the code for questions 4.1 and 4.2 in this code
module. [1 MARK]

4.1 Create a Sub Procedure named ReturnIt. [9 MARKS]


• This Sub Procedure should display the following and write the user-entered value to B11 (Note:
The user will enter the numbers 1, 2 or 3.):

• This Sub Procedure should call the Estimation Sub Procedure (see Question 4.2).
• Add the Smiley Face (colour it yellow) to the WorkSheet, which will call this Sub Procedure when
clicked. Refer to the example image at the end.

4.2 Create a Sub Procedure named Estimation. [9 MARKS]


• This Sub Procedure must not be accessible to other code modules.
• The Sub Procedure must read and store the following user-entered values in variables:
o Clown Costume (B2)
o Number of days (B6)
o Delivered? (B7)
o Before and after costume condition (must be used as string values) (B10 and B11)
• The DayFee Function Procedure must be called (see Question 5.1), and the returned result
must be written to B15.
• The DeliveryFee Function Procedure must be called (see Question 5.2), and the returned result
must be written to B16.
• The ConditionFee Function Procedure must be called (see Question 5.3), and the returned
result must be written to B17.

QUESTION 5
Create a code module named AllCalculations. Write the code for questions 5.1 - 5.3 in this code module.
[1 MARK]

4 of 5 UFS
Assignment 3 CSIS1683

5.1 Create a Function Procedure named DayFee. [6 MARKS]


• This Function Procedure must receive the clown costume and the number of days as parameters.
• Make use of a Select…Case to calculate the total day fee. Clown costume A costs R95.95 per day,
whereas clown costume B costs R75.95 and clown costume C R120 per day. Multiply the number
of days with the clown costume amount to calculate the total day fee. This fee must be returned
to the calling Sub Procedure.

5.2 Create a Function Procedure named DeliveryFee. [5 MARKS]


• This Function Procedure must receive the Yes or No value from the Delivered field as a
parameter.
• The delivery fee of R150 is only applicable if the customer asks for the costume to be delivered.
This value must be returned to the calling Sub Procedure.

5.3 Create a Function Procedure named ConditionFee. [4 MARKS]


• This Function Procedure must receive the before and after costume condition values as
parameters (note that these values are strings – see Question 4.2).
• The costume condition fee is calculated by subtracting the costume condition before value from
the costume condition after value and multiplying the answer with 39.9. You can assume that
the costume can be returned in the same condition or in a worse condition, but never in a better
condition. This value must be returned to the calling Sub Procedure.

EXAMPLE

SUBMISSION
ONLY the last submission on Blackboard will be marked.
DUE DATE: 12 September 2024 before 20:00 submitted on Blackboard.


5 of 5 UFS

You might also like