Home > Software engineering >  Help: VB creation process, function calculating factorial Numbers together
Help: VB creation process, function calculating factorial Numbers together

Time:09-20

I want to learn vb, recently will knock program to your computer after running out of the book display function is undefined, check out what the problem by themselves, teacher please help see new construction according to the requirements of the following pictures and code, thank you,

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,
  • Related