以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  为何此定义函数在命令窗口测试错误?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=72996)

--  作者:hnpykfq123
--  发布时间:2015/8/10 16:56:00
--  为何此定义函数在命令窗口测试错误?

下面是帮助文件中的一个自定义sum函数,为何在定义后调用显示“自定义函数sum执行出错”

Dim Code As string
Code = "Dim Val1 As Integer = 1" & vbcrlf
Code = Code & "Dim Val2 As Integer = 2" & vbcrlf
Code = Code & "Dim Sum As Integer = Val1 + Val2" & vbcrlf
Code = Code & "Return Sum"
Functions.Add("Sum",Code)
Functions.Complie() 


--  作者:有点蓝
--  发布时间:2015/8/10 17:05:00
--  
output.show(Functions.Execute("Sum"))
看看有没有值,有的话说明已经存在了,不能重复加

--  作者:大红袍
--  发布时间:2015/8/10 17:06:00
--  

Dim Code As String
Code = "Dim Val1 As Integer = 1" & vbcrlf
Code = Code & "Dim Val2 As Integer = 2" & vbcrlf
Code = Code & "Dim Sum As Integer = Val1 + Val2" & vbcrlf
Code = Code & "Return Sum"
Functions.remove("Sum")
Functions.Add("Sum",Code)
Functions.Complie()

Dim sum = Functions.Execute("sum")
msgbox(sum)