作业帮 > 综合 > 作业

vb 求 1×2×3×.×99×100=

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/20 08:20:55
vb 求 1×2×3×.×99×100=
Private Sub Form_Click()
Dim i As Integer
Dim sum As Integer
sum = 1
For i = 1 To 100 Step 1
sum = sum * i
Next i
End Sub
这个有什么问题啊?
vb 求 1×2×3×.×99×100=
sum定义为整型肯定会溢出的
必须定义为double
Private Sub CommandButton1_Click()
Dim i As Integer
Dim sum As Double
sum = 1
For i = 1 To 100 Step 1
sum = sum * i
Next i
TextBox1.Text = sum
End Su