下面的代码定义了一个简单的Sum函数:
Dim Code As stringCode = "Dim Val1 As Integer = 1" & vbcrlfCode = Code & "Dim Val2 As Integer = 2" & vbcrlfCode = Code & "Dim Sum As Integer = Val1 + Val2" & vbcrlfCode = Code & "Return Sum"Functions.Add("Sum",Code)Functions.Complie()
这样我们就可以在其余地方调用此函数:
Functions.Execute("Sum")
如何获取返回值sum的值