20.过程函数练习(1)
上机试试看下列程序的运行结果,
然后把语句“Dim sum As Integer”换成“Static Sum As Integer”再试试看——
Private Sub Command1_Click()
Dim A As Long
A = P(1) P(2) P(3) P(4)
Print A
End Sub
Private Function P(N As Integer)
Dim i As Integer
Dim sum As Integer
For i = 1 To N
sum = sum i
Next
P = sum
End Function
