Write a sub procedure named Count_Down that displays a countdown from “ 3 ” to “
ID: 665322 • Letter: W
Question
Write a sub procedure named Count_Down that displays a countdown from “3” to “1” using worksheet cells to represent the numbers. The numbers should be displayed as depicted in Figure 1.
1.
2. Write a sub procedure named Reset that will:
a) Replace the legend “GO!” with the legend “READY?” in cell E5. Use capital letters and BOLD font style for this legend, center the legend in cell E5, and set the interior color of cell E5 to RED.
b) Assign the sub procedure Reset to a rectangular shape button. The caption of the rectangular shape button should read “Reset”. The rectangular shape button should be visually appealing and its upper left corner should be aligned with the upper left corner of cell B7.
Explanation / Answer
Private Sub StartCmdBtn_Click()
Set myDocument = Worksheets(1)
'left to right
With myDocument.Shapes.AddShape(msoShapeRectangle, _
190, 44, 110, 12)
.Name = "Red Square"
.Fill.ForeColor.RGB = RGB(255, 0, 0)
.Line.DashStyle = msoLineDashDot
End With
'top to bottom
With myDocument.Shapes.AddShape(msoShapeRectangle, _
300, 44, 12, 110)
.Name = "Red Square"
.Fill.ForeColor.RGB = RGB(255, 0, 0)
.Line.DashStyle = msoLineDashDot
End With
'left to right
With myDocument.Shapes.AddShape(msoShapeRectangle, _
190, 154, 122, 12)
.Name = "Red Square"
.Fill.ForeColor.RGB = RGB(255, 0, 0)
.Line.DashStyle = msoLineDashDot
End With
'top to bottom
With myDocument.Shapes.AddShape(msoShapeRectangle, _
300, 154, 12, 110)
.Name = "Red Square"
.Fill.ForeColor.RGB = RGB(255, 0, 0)
.Line.DashStyle = msoLineDashDot
End With
'left to right
With myDocument.Shapes.AddShape(msoShapeRectangle, _
190, 256, 122, 12)
.Name = "Red Square"
.Fill.ForeColor.RGB = RGB(255, 0, 0)
.Line.DashStyle = msoLineDashDot
End With
' The above draws number 3
'delay for 2 seconds = sleep 2000
Application.Wait (Now + TimeValue("00:00:02"))
'after 2 seconds clear 3 and draw 2
For Each shape1 In myDocument.Shapes.msoShapeRectangle
shape1.Delete
Next shape1
End Sub
Private Sub CommandButton1_Click()
End Sub
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.