首页 | 社区 | 博客 | 招聘 | 文章 | 新闻 | 下载 | 项目交易 | 网友作品 | 读书 | ACM题库 | 源码
亲,您未登录哦! 登录 | 注册

利用API实现字符串表达式的计算

(加入日期: 2004-04-14 )

打印文章】【字体:

分享到:
Option Explicit
Private Declare Function EbExecuteLine Lib "vba6.dll" (ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long

Private Function ExecuteLine(sCode As String, Optional fCheckOnly As Boolean) As Boolean
    ExecuteLine = EbExecuteLine(StrPtr(sCode), 0&, 0&, Abs(fCheckOnly)) = 0
End Function


Sub calc(ByVal x As String)
Dim result
ExecuteLine "dim x as double"
ExecuteLine "x= " & x
ExecuteLine "clipboard.settext x"
result = Clipboard.GetText
MsgBox x & "=" & result
Set result = Nothing
End Sub

Private Sub Command1_Click()
calc Text1
End Sub

Private Sub Form_Load()
Text1.Text = "1+2*3-4/5"
End Sub

本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )

编程爱好者论坛

本栏最新文章