198k views
3 votes
Create a Sub called "daisyDecisions" that runs when you click a button. In this sub, you will create a program that determines whether he/she loves you, or loves you not. The program should receive, as an input, the number of petals on the flower (i.e., have a variable for petals) and then use that number to determine the output of the program: if the number of petals is even, then the program should output that he/she loves you not, if odd, then he/she loves you.

User Blago Eres
by
5.2k points

1 Answer

5 votes

Answer:

see explaination

Step-by-step explanation:

Please find the screenprint and the VBA code. As shown in the screenprint, range B1 is used to enter the number of petals. If you want to use a different cell for petals input, then change the code accordingly.

Also, the VBA code is placed in the Sheet1 module. No new modules are inserted.

Screenprint: see attachment for screenshot

VBA Code:

Private Sub CommandButton1_Click()

Call daisyDecisions

End Sub

Private Sub daisyDecisions()

Dim remainder As Integer

Dim noOfPetals As Integer

noOfPetals = Sheet1.Range("B1").Value

remainder = noOfPetals Mod 2

If remainder <> 0 Then

MsgBox "He/She loves you!!!"

Else

MsgBox "He/She loves you not!!!"

End If

End Sub

Create a Sub called "daisyDecisions" that runs when you click a button. In-example-1
User Max DeLiso
by
5.0k points