Public Function power(ByVal i As Long)
On Error Resume Next
Debug.Assert i > 0
power = 1
While i > 0
power = power * i
If Err = 6 Then power = -1: Exit Function
i = i - 1
Wend
End Function
Private Sub Command1_Click()
Dim ReturnValue, I
ReturnValue = Shell("Calc.EXE", 1) ' 运行计算器。
AppActivate ReturnValue ' 激活计算器。
For I = 1 To 100 ' 设置计数循环。
SendKeys I & "{*}", True ' 按下按键给计算器
Next I ' 将所有 I 值相乘。
SendKeys "=", True ' 取得总合。