【单选题】如下程序段,要计算s=1+(1+2)+(1+2+3),已知主调程序为:Private Sub Button1_Click(…) Handles Button1.Click Dim s% = 0,i% For i = 1 To 3 s = s + sum(i) Next MsgBox(“s=” & s)End Sub如下sum函数过程及变量声明,不能实现题目要求的是 。
A.
Function sum(ByVal n%) Dim c% c = c + n sum = c End Function
B.
Function sum(ByVal n%) Static c% c = c + n sum = c End Function
C.
Public c% Function sum(ByVal n%) c = c + n sum = c End Function
D.
Dim c% Function sum(ByVal n%) c = c + n sum = c End Function
【单选题】如下程序段,要计算s=1+(1+2)+(1+2+3),已知主调程序为:Private Sub Command1_Click() Dim s%, i% For i = 1 To 3 s = s + sum(i) Next MsgBox ("s=" & s)End Sub则下列sum函数过程正确的是__________。
A.
Function sum%(ByVal n%) Static c% c = c + n sum = c End Function
B.
Function sum%(ByVal n%) Dim c% c = c + n sum = c End Function
C.
Function sum%(ByVal n%) Public c% c = c + n sum = c End Function
D.
Function sum%(ByVal n%) Private c% c = c + n sum = c End Function