CodePudding user response:
1) determine the VB6, rather than VB.Net,2) put a piece of code is input to the form below in the code window,
3) code does not include a line number,
4) Print statement output is temporary and form refresh once see, Suggestions for MsgBox statement,
CodePudding user response:
The code there is no problem, can be modified as follows:Private Sub CountAll (ParamArray num ())
Dim total As Long, As the Variant x
Dim n As an Integer, s As Long
Total=0
For Each x In num
S=1
For n=2 To x
S=s * n
The Next n
Total=total + s
Next x
MsgBox total
End Sub
Private Sub Command1_Click ()
Call CountAll (1, 5, 8, 10)
End Sub
1 as a loop variable, n initialization in the For statement, there is no need For assignment before,
Factorial starting from 2 to 2 times the 1 no actual meaning,