VB编程 求教

来源:百度知道 编辑:UC知道 时间:2024/05/04 17:31:26
Private Sub Form1_Click()
Dim sum, a, b, s As Integer
sum = 0
a = 1
For s = 1 To 10

For b = s To 1 Step -1
a = a * b

Next b

sum = sum + a
Next s
Print sum

End Sub

是求从1到10的阶乘之和,运行时没提示出错。但是没结果显示出来,菜鸟这里请教各位大侠帮帮忙了

Private Sub Form1_Click() 改成 Private Sub Form_Click()
就是把form1改成form

VB中的Print语句不是直接能打印出来的,除非你在此之前加上一个打印控件,并加上下列语句:
CommonDialog1.DialogTitle = "Select a printer"
CommonDialog1.ShowPrinter
Printer.EndDoc