一个公式输入的问题!

liuchaosmile 2004-04-20 03:45:30
例如: text1 command1 a as double

在 text1 中输入 6*6 按下 command1 能不能使得 a=6*6 ?

我试了 a=cdbl(text1.text) 好像不行!

请高手指教!
...全文
52 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
cslf 2004-04-20
  • 打赏
  • 举报
回复
用split把"+-*/"等运算符和操作数分离出来,再处理。
of123 2004-04-20
  • 打赏
  • 举报
回复
全部代码:
Option Explicit
Dim flag As Boolean

Private Sub Command1_Click(Index As Integer) '一个按钮数组:0-9,+,-,*,/,^
If flag Then
Text1 = ""
flag = False
End If
Text1 = Text1 & Command1(Index).Caption
End Sub

Private Sub Command2_Click() '按钮=
Dim s

If Text1 = "" Then Exit Sub
On Error GoTo errHandler

Set s = CreateObject("ScriptControl")
s.Language = "VBScript"
Text1 = s.Eval(Text1)
Set s = Nothing
flag = True
Exit Sub
errHandler: Text1 = "E"
End Sub

Private Sub Command3_Click() '按钮C
Text1 = ""
End Sub
northwolves 2004-04-20
  • 打赏
  • 举报
回复
参考:

http://www.csdn.net/Develop/read_article.asp?id=26383


http://www.csdn.net/Develop/read_article.asp?id=26381
道素 2004-04-20
  • 打赏
  • 举报
回复
你可以试试microsoft script control

ScriptControl1.Eval (text1.Text)

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧