Question
Need help writing VBA code VBA is going to tell the users fortune! VBA will ask the user to think of a number between 1
Need help writing VBA code
VBA is going to tell the users fortune! VBA will ask the user to think of a number between 1 and 9. The user will then see a series of message boxes with the following instructions:
-
Multiply their number by three.
-
Add three to the result.
-
Multiply the whole thing by three.
-
Add the digits of their final number together.
VBA will read their minds as they look at their fortune on the spreadsheet and highlight the message corresponding to their final number even though the program never asked what number they originally picked!
Here are some specific instructions about how I want you to do the above problem. Read all these instructions carefully. A flowchart is on the next page.
-
Use the FortuneTelling.xlsx workbook to complete this problem, put your code in a module. Save your work often! And dont forget to save it as an .xlsm, the file you get with the assignment is a .xlsx.
-
Use all the conventions we have used in class.
-
Use four variables to hold the four instruction bullets above (one variable per instruction.)
-
Use five message boxes. One to give the user the original instruction about thinking of a
number between 1 and 9, and one using each of the four message variables from instruction 3.
-
Save your work often!
-
Nine will be their final answer. If the user correctly follows the instructions, their result will be
9, no matter the original number chosen. Dont believe me? Try it! Show the user their fortune by highlighting cell B10. This isnt something weve done before, so here is a hint. To fill in a background color to a cell use the following on a range object: .Interior.ColorIndex = 26. (26 is a bright pink color, if you want to use a different color experiment with a different number!)
-
Note, you do not need to ask the user for the number they are choosing or do any calculations. Only do the things you are being asked to do in these instructions. If you ask them for their original number, you arent reading their mind!
-
Submit your workbook to Canvas by the due date, which you can see on the assignment in Canvas. Canvas will block you from submitting work even one second after the assignment closes. Do not be late!
-
This is an individual, not a group assignment.
-
Save your work often!
-
If you have a question about an instruction, ask me via Teams chat.
-
Dont overcomplicate this. It is meant to be a straightforward set of instructions. I am not
trying to trick you. Just follow the instructions and you will be fine. If it isnt mentioned on this page, I dont care about it. You dont need to ask if you should do xyz. If its mentioned here you should, if it isnt, you shouldnt.
Flowchart: Start magic procedure=> define 4 variables => Assign value to variables => Five message boxes => Highlight cell B10=> End magic procedure
1 You will own a purple cow. |
2 You will get married 25 times. |
3 You will be a world famous harmonica player. |
4 You will star in a reality show about cheese farmers. |
5 You will win Iceland in a high stakes poker game. |
6 You will eat nothing but bologna from the ages of 66 to 68. |
7 You will be a passenger on the first Mars colonization effort. |
8 You will discover a deep sea snail which will be named after you. |
9 You will pass this assignment. |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started