Use API to implement string expressions

zhaozj2021-02-16  56

The following implementation string expression calculation code is adapted by the author's collection of this forum code, which is unclear, which netizen is provided, thank you very much.

Option EXPLICITPRIVATE DECLARE FUNCTION EBEXECUTELINE LIB "VBA6.DLL" (Byval PstringtoExec 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) = 0nd function

Sub calc (ByVal x As String) Dim resultExecuteLine "dim x as double" ExecuteLine "x =" & xExecuteLine "clipboard.settext x" result = Clipboard.GetTextMsgBox x & "=" & resultSet result = NothingEnd Sub

Private submmand1_click () Calc text1end Sub

Private Sub Form_Load () text1.text = "1 2 * 3-4 / 5" End Sub

转载请注明原文地址:https://www.9cbs.com/read-23731.html

New Post(0)