新建一个工程,添加个命令按钮和一个文本框代码如下:Private Sub Command1_Click()n = Val(Text1.Text)s = 0 '存结果For i = 1 To n t = 1 '临时存积的变量 For j = 1 To i '计算阶乘 t = t * j Next j s = s + tNext iPrint "结果为:" & sEnd Sub