情况是这样的。我想做到在text控件里面输入算式,比如3+5*4 点某个按键后自动根据算式计算结果到text里面?

解决方案 »

  1.   


    最简单就是采用 ScriptControlDim 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"
      

  2.   

    Private Sub Command1_Click()
    Dim sc As Object
    Set sc = CreateObject("ScriptControl")
    sc.Language = "VBScript"Text2.Text = sc.Eval(Text1.Text)
    End Sub
    Private Sub Form_Load() '\'系统初始化
     Text1.Text = "3+5*4"
    End Sub