欢迎访问服务器技术网-www.fuwuqijishu.com

+…+10!并用print显示结果?

程序设计 fuwuqijishu 2年前 (2022-10-01) 27次浏览 0个评论 扫描二维码

关于用自定义函数(function),求1!+2!+3!+…+10!并用print显示结果?一定要在VB里求:

用自定义函数(function),求1!+2!+3!+…+10!并用print显示结果?
Private Sub Command1_click()

End Sub
function fact(x as integer) as long

end function
的问题

Private Sub Command1_click()
Dim i As Integer
Dim Result As Long

For i = 1 To 10
Result = Result + fact(i)
Next

Print Result
End Sub
Function fact(x As Integer) As Long
Dim i As Integer
Dim Result As Long

Result = 1

For i = 1 To x
Result = Result * i
Next i

fact = Result
End Function

喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

Warning: error_log(/www/wwwroot/fuwiqijishu/wp-content/plugins/spider-analyser/#log/log-2409.txt): failed to open stream: No such file or directory in /www/wwwroot/fuwiqijishu/wp-content/plugins/spider-analyser/spider.class.php on line 2900