以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  对计算结果重复运算  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=23295)

--  作者:明丰
--  发布时间:2012/9/8 8:15:00
--  对计算结果重复运算

对计算结果重复运算

增加一个自定义函数,名称为hd,代码为:
Dim d As String = Args(0)
Dim d1 As String
For i As Integer = 0 To d.Length - 1
d1 = val(d1) + val(d(i)) ^ 3
Next
Return d1

命令窗口执行下面代码:得到数字3及其倍数的“黑洞”,结果为:153
Dim d As String = 3
Dim T As String
If d = Functions.Execute("hd",(d)) Then
T = Functions.Execute("hd",(d))
ElseIf Functions.Execute("hd",(d)) = Functions.Execute("hd", _
(Functions.Execute("hd",(d)))) Then
T = Functions.Execute("hd",(Functions.Execute("hd",(d))))
ElseIf Functions.Execute("hd",(Functions.Execute("hd",(d)))) =  _
Functions.Execute("hd",(Functions.Execute("hd",(Functions.Execute("hd",(d)))))) Then
T = Functions.Execute("hd",(Functions.Execute("hd",(Functions.Execute("hd",(d))))))
ElseIf Functions.Execute("hd",(Functions.Execute("hd",(Functions.Execute("hd",(d)))))) = _
Functions.Execute("hd",(Functions.Execute("hd",(Functions.Execute("hd", _
(Functions.Execute("hd",(d)))))))) Then
T = Functions.Execute("hd",(Functions.Execute("hd",(Functions.Execute("hd",(Functions. _
Execute("hd",(d))))))))
\'…… 执行100次,还是不符合条件,终止执行
End If
output.show(T)

按照上面的规律,请问自定义函数如何设置?


--  作者:lin_hailun
--  发布时间:2012/9/8 8:56:00
--  
 其实这个问题不太复杂吧?

Dim d As String = 3
Dim T As String
Dim temp As String = d
For i As Integer = 0 To 99
    d = temp
    temp = Functions.Execute("hd", temp)
    If d = temp Then
        T = temp
        Exit For
    End If
Next
Output.Show(T)

--  作者:明丰
--  发布时间:2012/9/8 8:58:00
--  

谢谢!

 

[此贴子已经被作者于2012-9-8 8:59:43编辑过]