In: Computer Science
Assign a button for each macro. Each macro should also receive its inputs through an input box and display its outputs through a msgbox.
Hint: Use the Mod operator to determine if a number is odd or even:
The Mod operator will return the remainder of one number divided by another, for instance:
11 Mod 2 = 1, 11 Mod 3 = 2, 11 Mod 4 = 3
You can also apply this operator on variables (ie, myVariable Mod 2 would return the remainder of your variable divided by 2).
Be sure to write your code in a module in the workbook you will submit, not in your personal workbooks or sheets. To access the correct module, go to your “Visual Basic,” right-click “Microsoft Excel Objects” in the workbook you are submitting, and then click “Insert” and “Module.”
Code
Sub daisyDecisions()
Dim num_of_petals As Integer
num_of_petals = CInt(InputBox("Enter number of petals on the
flower"))
If num_of_petals Mod 2 = 0 Then
MsgBox ("The Person Loves you not")
Else
MsgBox ("The Person Loves you")
End If
End Sub
Output
If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.