标题:[讨论]帮我改改调用Sub 过程
取消只看楼主
xz3501
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2007-5-12
 问题点数:0 回复次数:1 
[讨论]帮我改改调用Sub 过程

1. 编写计算1!+2!+3!+……n!的Sub过程,在窗体的Click事件中调用该过程,输出计算结果。
我写的代码:
Sub factS(ByVal n As Integer, fac)
fac = 1
For i = 1 To n
fac = fac * i
nexti
End Sub


Private Sub Form_Click()
Dim a As Integer, b As Integer
a = Val(InputBox("输入项数"))
Call factS(a, fac)
??????????

Print fac;
End Sub


[此贴子已经被作者于2007-6-4 16:11:52编辑过]

搜索更多相关主题的帖子: Sub 改改 
2007-06-02 10:28
xz3501
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2007-5-12
得分:0 

我的代码在下面,哪里有问题啊?
Sub factS(ByVal n As Integer, fac)
fac = 1
For i = 1 To n
fac = fac * i
Next i
End Sub


Private Sub Form_Click()
Dim a As Integer, b As Integer, sum As Double
a = Val(InputBox("输入项数"))
b = 0
For i = 1 To a
b = b + 1
Call factS(a, fac)
sum = sum + fac
Next i
Print fac;
End Sub


[此贴子已经被作者于2007-6-4 18:58:10编辑过]


2007-06-04 16:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-144256-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.944451 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved