首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
现有如下程序: Private Sub Command1_Click() s=0 For i=1 To 5 s=s+f(5+i) Next Print s End Sub Public Function f(x As Integer
现有如下程序: Private Sub Command1_Click() s=0 For i=1 To 5 s=s+f(5+i) Next Print s End Sub Public Function f(x As Integer
admin
2015-08-28
17
问题
现有如下程序:
Private Sub Command1_Click()
s=0
For i=1 To 5
s=s+f(5+i)
Next
Print s
End Sub
Public Function f(x As Integer)
If x>=10 Then
t=x+1
Else
t=x+2
End If
f=t
End Function
运行程序,则窗体上显示的是( )。
选项
A、38
B、49
C、61
D、70
答案
B
解析
程序中过程f的功能是参数值大于等于10时,返回参数加1的值,否则返回参数加2的值。因此按钮事件中s值的计算过程如下:
i=1时,s=0+f(5+1)=8;
i=2时,s=8+f(5+2)=8+9=17;
i=3时,s=17+f(5+3)=17+10=27;
i=4时,s=27+f(5+4)=27+11=38;
i=5时,s=38+f(5+5)=38+11=49;
因此最终在窗体上输出的是49。
转载请注明原文地址:https://kaotiyun.com/show/B1Lp777K
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
在软件工程中,白箱测试法可用于测试程序的内部结构。此方法将程序看做是______。
为了把一个记录型变量的内容写入文件中指定的位置,所使用的语句的格式为______。
某人在窗体上画了一个名称为Timer1的计时器和一个名称为Labe11的标签,计时器的属性设置为Enabled=True,Interval=0,并编程如下。希望在程序运行时,可以每2秒在标签上显示一次系统当前时间。PrivateSubTimer
下面对对象概念描述错误的是______。
下面叙述中不正确的是______。
在面向对象方法中,一个对象请求另一对象为其服务的方式是通过发送______。
MicrosoftVisualBasic6.0包括三种版本,其中不包括______。
下列四个关于DoEvents语句的叙述中,正确的是______。
表达式(2+8*3)/2的值是______。
随机试题
比纳-西蒙量表是世界上第一个标准化智力测验量表,产生于()年。
世界上最早编制、最有影响的股价指数是()
下列内容不符合防火门门扇与门框的配合活动间隙要求的是()。
甲企业期初资产总额为1000万元,期末资产总额为1500万元,本期负债减少了200万元,期初所有者权益为700万元,则期末所有者权益为()万元。
事业单位借入的款项发生的利息应计入()。
根据票据法律制度的规定,下列有关在票据上签章效力的表述中,正确的有()。
MMPI—2适用于()。
甲每4天进城一次,乙每7天进城一次,丙每12天进城一次,某天三人在城里相遇,那么三人下次相遇至少需要多少天?( )
从所给的四个选项中,选择最合适的一个填入问号处,使之呈现一定的规律性。
【S1】【S8】
最新回复
(
0
)