VBA 递归求解答

VBA 递归求解答,第1张

这个就是递纤冲归的精神所在了。你可以随便弄个数进去试试。比野核如说5,代颂竖掘进去就是s(5)=5*s(5-1)=5*s(4)=5*4*s(4-1)=5*4*s(3)=5*4*3*s(3-1)=5*4*3*s(2)=5*4*3*2*s(2-1)=5*4*3*2*s(1)=5*4*3*2*1=120

就是不断的把自己代进去,越代越小,直到等于1,那就是1了。

您能提出这等 问题说明您的VBA水平有一定火候了,请看

Function Fllst(Pth$)

Dim Fso As Object

Dim Fld, Fl

Set Fso = CreateObject("卜腊枣Scripting.FileSystemObject")

Set Fld = Fso.getfolder(Pth)

On Error Resume Next

For Each Fl In Fld.Files

[A65536].End(3)(2) = Fl.path

Next

For Each Fl In Fld.SubFolders

Fllst (Fl.path)

Next

End Function

Sub getList()

Dim Fso As Object

Set Fso = CreateObject("Scripting.FileSystemObject")

[A:A].ClearContents

Application.ScreenUpdating = False

Fllst (CreateObject("局岁Shell.Application").BrowseForFolder(0, "请选择目录型拆", 0, "").Self.path)

Application.ScreenUpdating = True

Set Fso = Nothing

End Sub

Sub test()

n = 5

For i = 1 To n

sumtest = suntest + (-1) ^ i * i

Next i

MsgBox sumtest

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12253205.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-22
下一篇 2023-05-22

发表评论

登录后才能评论

评论列表(0条)

保存