首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
编写如下程序: Private Sub Command1_Click() Dim m As Integer,n As Integer n=2 For m=1To3 Print proc(n); Next m End Sub Function proc(i
编写如下程序: Private Sub Command1_Click() Dim m As Integer,n As Integer n=2 For m=1To3 Print proc(n); Next m End Sub Function proc(i
admin
2020-04-18
23
问题
编写如下程序:
Private Sub Command1_Click()
Dim m As Integer,n As Integer
n=2
For m=1To3
Print proc(n);
Next m
End Sub
Function proc(i As Integer)
Dim a As Integer,Static b As Integer
a=a+1:b=b+1
proc=a*b+i
End Function
程序运行后,单击命令按钮Command1,输出结果为
选项
A、3 3 3
B、3 4 5
C、3 5 6
D、1 2 3
答案
B
解析
使用Dim关键字定义的是动态局部变量,过程执行结束后即被释放;使用Static关键字定义的是静态局部变量,过程执行结束后仍然保留。本题中函数proc中的局部变量a是动态变量,b是静态变量。即每次函数调用后b的值会保留。先后三次调用proc(n)方法,依次输出3、4、5。
转载请注明原文地址:https://kaotiyun.com/show/brTp777K
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
在数据库设计中,将E-R图转换成关系数据模型的过程属于( )。
编写如下程序:PrivateSubCommand1_Click()StaticxAsIntegerIfxThenx=x+10Elsex=x+1PrintxEndSub程序运行后,第三次单
下面说法中错误的是
在软件开发中,需求分析阶段可以使用的工具是( )。
在窗体上画一个命令按钮(其Name属性为Command1),然后编写如下代码:OptionBase1PrivateSubCommand1_Click()Dimaa=Array(1,2,3,4):j=1
要求在程序运行时,如果按住鼠标左键不放而移动鼠标,鼠标的位置坐标同步显示在窗体右上角的标签(名称为Label1)中,如右图所示,放开鼠标左键后,停止同步显示。下面可以实现此功能的程序是( )。
若在窗体模块的声明部分声明了如下自定义类型和数组:PrivateTyperecCodeAsIntegerCaptionAsStringEndTypeDimarr(5)Asrec则下
双精度浮点数的类型说明符为
双精度浮点数的类型说明符为
随机试题
铲斗挖泥船应根据不同土质选用不同铲斗,可塑黏土宜配备()。
Herearesomesuggestionsthatprovehelpfulforthosewhoarepreparingforajobinterview.Insomeway,a(n)【B1】______interv
患者,18岁。发热起病3天后下降,伴恶心、呕吐、尿色深如豆油样,病程第8天出现嗜睡,继之神志不清,巩膜皮肤深度黄疸,肝界缩小。诊断应考虑
女婴,胎龄36周。出生时体重2000g,体温36.4℃,脉搏130次/分,呼吸45次/分,心、肺无异常,吸吮力弱。该患儿是
临床上最简便的用于确诊疟疾的实验室检查方法是
下列关于正态分布特点的描述,错误的是
拔牙术后,牙槽窝内血块开始机化的时间是拔牙后A.30分钟B.2小时C.24小时D.3~4天E.1个月
永续年金是一组在无限期内金额()、方向()、时间间隔()的现金流。
关于陕西的饮食文化,下列说法正确的是:
下列中央银行的业务中,属于对政府提供的业务是()。
最新回复
(
0
)