Dim sc As ScriptControl
Set sc = New ScriptControl
With sc
.Language = "VBScript"
End WithDim abc As String
abc = "123456789"Dim sExp As String
sExp = "Mid(" & abc & ",1,2)"Dim sRet As String
sRet = sc.EVal(sExp)MsgBox sRet
Set sc = New ScriptControl
With sc
.Language = "VBScript"
End WithDim abc As String
abc = "123456789"Dim sExp As String
sExp = "Mid(" & abc & ",1,2)"Dim sRet As String
sRet = sc.EVal(sExp)MsgBox sRet
scriptControl控件,而不是象Un1那样用 new !
我的方法需要在“工程”->“引用”中加入"Microsoft Script Control",或者使用:
set sc = CreateObject("ScriptControl")这种方法允许在Script代码中Set Script 引擎为Nothing释放资源,而控件方式则不允许。