此示例使用 Shell 函数启动计算器应用程序,然后通过使用 SendKeys 类的 SendWait 方法发送击键来将两个数值相乘。
示例
Dim ProcID As Integer
' Start the Calculator application, and store the process id.
ProcID = Shell("CALC.EXE", AppWinStyle.NormalFocus)
' Activate the Calculator application.
AppActivate(ProcID)
SendKeys.SendWait("22")
SendKeys.SendWait("*")
SendKeys.SendWait("44")
SendKeys.SendWait("=")
编译代码
此示例需要:
- 对 System.Windows.Forms 命名空间的引用。
本文介绍了一个使用VBA启动计算器并进行乘法运算的例子。该示例通过Shell函数启动计算器,接着利用SendKeys类的SendWait方法输入数值及运算符实现自动计算。
2万+





