东拼西凑 ^_^- '获取剪贴板中的算式,计算后粘贴
-
- '获取剪贴板内容
- Dim Form, TextBox
- Set Form = CreateObject("Forms.Form.1")
- Set TextBox = Form.Controls.Add("Forms.TextBox.1").Object
- TextBox.MultiLine = True
- If TextBox.CanPaste Then
- TextBox.Paste
- 'WScript.Echo TextBox.Text
- End If
-
- '计算
- Dim strExp
- 'strExp = TextBox.Text & "=" & Eval(TextBox.Text) '显示算式及结果
- strExp = strExp & Eval(TextBox.Text) '仅显示结果
-
- '写回计算结果到剪贴板
- strCopy=strExp
- Call SetClipboardText(strCopy)
- Sub SetClipboardText(Text) '写入信息到剪切板
- Dim wsh
- Set wsh = CreateObject("WScript.Shell")
- wsh.Run "mshta vbscript:ClipboardData.SetData("&chr(34)&"text"&chr(34)&"," &Chr(34)& Text &Chr(34)& ")(close)",0,True
- set wsh=Nothing
- End Sub
- createobject("wscript.shell").Sendkeys("^v") '模拟ctrl+v
复制代码
|