回答了,别重复提问了
遂昌网站建设公司创新互联,遂昌网站设计制作,有大型网站制作公司丰富经验。已为遂昌数千家提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的遂昌做网站的公司定做!
dim i%,jx#
i=1
jx=1
do while i=10
jx=jx*i
i=i+1
loop
print jx
Private Sub Command1_Click()
Dim A, B, C
A = 10
B = 3
C = f(A) / (f(B) * f(A - B))
Print C
End Sub
Private Function f(n)
Dim I As Integer
f = 1
For I = 1 To n
f = f * I
Next I
End Function
首先在窗体上画两个控件:TextBox1和Button1
TextBox1用来输入需要计算那个数的阶乘
双击Button1进入输入代码,代码如下
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim Factorial As Integer = 1 '定义一个变量用来记录阶乘的结果
Dim count As Integer '定义一个变量用来记录需要计算那个数的阶乘
Dim i As Integer = 1 '定义一个数用来循环
count = Int(Val(Me.TextBox1.Text)) '把TextBox1的值赋值给count
Do While i = count '下面开始计算阶乘
Factorial = Factorial * i '计算阶乘
i += 1 '自增1
Loop
MessageBox.Show(Int(Val(Me.TextBox1.Text)) "的阶乘是:" Factorial, "完成", MessageBoxButtons.OK) '弹出计算结果
Catch ex As Exception '出错提示
MessageBox.Show(Err.Description, "出错了", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
两个textbox,一个command
Private Sub Command1_Click()
Dim i As Integer, sum As Double, sel As Double
sum = 0
sel = 1
If Trim(Text1.Text) = "" Then
MsgBox "没有输入要求的阶乘数:"
Exit Sub
End If
If Not IsNumeric(Text1.Text) Then
MsgBox "输入的不是数字,请重新输入"
Exit Sub
End If
For i = 1 To Val(Text1.Text)
sel = sel * i
sum = sum + sel
Next i
Text2.Text = sum
End Sub
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款