联系方式

站长:
联系人:赵先生
手机:18183869808

QQ 64816414
保健茶:

联系人:罗小姐

电话:15368244381

QQ 834856496

利用API 实现字符串表达式的计算
发布者:zaq 类型:杂器快贴 发布时间:2018-11-18 5:01:14 浏览:3292次 [回复]
下面实现字符串表达式计算代码由笔者收藏的本论坛代码改编,记不清是哪位网友提供的了,非常感谢。

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


源地址:http://www.zaqi.net/word_view.asp?files_id=489
上一篇:Win2003的服务器修改默认上传200k和下载4M的限制
下一篇:利用API 实现字符串表达式的计算
零售:¥45元
零售:¥35元
批发:¥29元
零售:¥148元
零售:¥35元
杂器网络版权所有  免责声明