在vb中,分别用过程和函数编写求阶乘的子程序的程序代码怎么写?
2013-06-29
展开全部
函数的
Function Jc(x As Integer)
s = 1
For i = 1 To x
s = s * i
Next i
Jc = s
End Function
Private Sub Command1_Click()
Text2.Text = Jc(Val(Text1.Text))
End Sub
过程的
Sub Jc()
s = 1
For i = 1 To Val(Text1.Text)
s = s * i
Next i
Text2.Text = s
End Sub
Private Sub Command1_Click()
Call Jc
End Sub
Function Jc(x As Integer)
s = 1
For i = 1 To x
s = s * i
Next i
Jc = s
End Function
Private Sub Command1_Click()
Text2.Text = Jc(Val(Text1.Text))
End Sub
过程的
Sub Jc()
s = 1
For i = 1 To Val(Text1.Text)
s = s * i
Next i
Text2.Text = s
End Sub
Private Sub Command1_Click()
Call Jc
End Sub
2013-06-29
展开全部
Private Function fact(ByVal x As Integer) As Long
Dim i As Integer
Dim r As Longr = 1
For i = 1 To x
r = r * i
Next
fact = r
End Function
Dim i As Integer
Dim r As Longr = 1
For i = 1 To x
r = r * i
Next
fact = r
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询