VB编程题求帮助
1、程序运行后(程序界面如图1.1所示),在Text1中输入任一正整数n,当点击“计算”按钮进行计算n!,并在Text2中显示该计算结果。PrivateSubComman...
1、程序运行后(程序界面如图1.1所示),在Text1中输入任一正整数n,当点击“计算”按钮进行计算n!,并在Text2中显示该计算结果。
Private Sub Command1_Click()
<语句块> '计算n!,并在Text2中显示出来
End Sub 展开
Private Sub Command1_Click()
<语句块> '计算n!,并在Text2中显示出来
End Sub 展开
3个回答
展开全部
Private Sub Command1_Click()
jc = 1
For i = 1 To Val(Text1)
jc = jc * i
Next i
Text2 = jc
End Sub
jc = 1
For i = 1 To Val(Text1)
jc = jc * i
Next i
Text2 = jc
End Sub
追问
为什么要这样解答呢?
追答
Private Sub Command1_Click()
jc = 1 '给变了jc赋初始值,否则,它的值为0,乘以任何数还等于0
For i = 1 To Val(Text1) 'Val(Text1)是将text1里面的文本变成数值
jc = jc * i '将jc从1到text1里面值累乘
Next i
Text2 = jc
End Sub
展开全部
Private Sub Command1_Click()
n = Text1.Text
s = 1
For i = 1 To n
s = s * i
Next i
Text2.Text = s
End Sub
n = Text1.Text
s = 1
For i = 1 To n
s = s * i
Next i
Text2.Text = s
End Sub
追问
为什么要这样解答呢?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim x as integer
x = Text1.Text
k = 1
For n = 1 To x
k = k * n
Next n
Text2.Text = k
End Sub
Dim x as integer
x = Text1.Text
k = 1
For n = 1 To x
k = k * n
Next n
Text2.Text = k
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询