I created a simple count down to delay the display of my math result. The strange thing happen was, one of my math input (Sub1) not get to display before the count down. Can anyone help me with what's wrong in the code below?
Code:
' Function: Making Number from 3 to 10, with count downSub MakingNumber()
Dim Main As Double
Dim Sub1 As Double
Dim Result As Double
Dim Text As String
Dim WShell As Object: Set WShell = CreateObject("WScript.Shell")
Dim strCnt As String
'Clear all value
Range("C2") = ""
Range("B4") = ""
Range("D4") = ""
' Random assign values and compute the results
Main = WorksheetFunction.RandBetween(3, 10)
Sub1 = WorksheetFunction.RandBetween(1, (Main - 1))
Result = Main - Sub1
' Display the values of the question
Range("C2") = Main
Range("B4") = Sub1
' Count Down
For i = 0 To 4
strCnt = Main & " - " & Sub1 & " = ? " & vbCrLf & "Count Down " & (5 - i)
WShell.Popup strCnt, 1, "CountDown", vbOKOnly
Next i
' Display the result
Range("D4") = Result
Text = Main & " - " & Sub1 & " = " & Result
MsgBox Text, , "Result"
End Sub