单选题
Access
题号 #2980781
|
在窗体中有一个命令按钮Commandl,编写事件代码如下:
Private Sub Commandl_Click( )
Dim SAsInteger
S=P(1)+P(2)+P(3)十P(4)
debu9.Print S
End Sub
Public Function PfN AS Integer)
Dim Sum As Integer
Sum=0
Fori=l ToN
Sum=Sum+i
Nexti
P=Sum
End Function
打开窗体运行后,单击命令按钮,输出结果是( )。【程序设计综合知识】
参考答案
B
答案解析
从函数P的代码可知,其功能是计算从1~N的和,在命令按钮的单击事件代码中,可知S为P(1)、P(2)、P(3)、P(4)的和,显然P(1)=1,P(2)=1+2=3,P(3)=1+2+3=6,P(4)=1+2+3+4=10,所以S=1+3+6+10=20。
你可能感兴趣的试题
A.37 55 64 28 19 19
B.10 5020
C.10 50 200
D.37 55 64 28 19
A.OnErrorThen标号
B.OnErrorGot0标号
C.On Error Resume Next
D.On Error Got0 0