新建From1(窗体),新建Text1(TextBox),新建Command1(按钮CommandButton),代码:
Private Sub Command1_Click() Dim objSC As Object Set objSC = CreateObject("ScriptControl") objSC.language = "vbs" MsgBox objSC.eval(Text1.Text) End Sub
在Text1中输入1+2+3,点击Command1可以看到:
6