在窗体上有一个命令按钮Command1,通用过程fun和命令按钮的事件过程如下: Private Function fun(ByVal m As Integer) If m Mod 2=0 Then fun=

admin2013-01-23  23

问题 在窗体上有一个命令按钮Command1,通用过程fun和命令按钮的事件过程如下:    Private Function fun(ByVal m As Integer)         If m Mod 2=0 Then              fun=2         Else              fun=1         End If    End Function    Private Sub Command1_Click()    Dim i As Integer,s As Integer        s=0        For i=1 To 5              s=s+fun(i)        Next        Print s    End Sub    程序运行后,单击命令按钮,则窗体上输出(    )。

选项 A、6
B、7
C、8
D、9

答案2

解析 本题比较简单,只要根据程序的执行条件和顺序就可以运算出该程序的最后输出结果。程序运算过程为:当i=1时,s=s+ fun(i)=1;当i=2时,s=s+fun(i)=3;当i=3时,s=s+fun(i)=4;当 i=4时,s=s+fun(i)=6;当i=5时,s=s+fun()=7。
转载请注明原文地址:https://kaotiyun.com/show/arhp777K
0

最新回复(0)