首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
编写如下程序: Private Sub Commandl_Click() Dim m As Integer,n As Integer n=2 For m=1 To 3 Print proc(n);
编写如下程序: Private Sub Commandl_Click() Dim m As Integer,n As Integer n=2 For m=1 To 3 Print proc(n);
admin
2018-10-15
19
问题
编写如下程序:
Private Sub Commandl_Click()
Dim m As Integer,n As Integer
n=2
For m=1 To 3
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
程序运行后,单击命令按钮Commandl,输出结果为
选项
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/0UFp777K
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
(1)在名称为Form1,标题为“测试”的窗体上添加一个名称为Frame1、标题为“字体”的框架。在框架内再添加两个名称分别为Opt1和Opt2、标题分别为“隶书”和“宋体”的单选按钮。程序运行后的窗体如图所示。注意:存盘时必须存放在考生文件夹下
若窗体上有一个名为Command1的命令按钮,并有下面的程序:PrivateSubCommand1_Click() Dimarr(5)AsInteger Fork=1To5 arr(k)=k Nextk prog
以下关于VB的叙述中,错误的是( )。
在窗体上画一个名称为List1的列表框,然后编写如下程序:PrivateSubForm_Click()Fori=1To10Item="Item"&iList1.AddItemItem
要使得文件列表框File1中只显示文件扩展名为jpg的图片文件,则下列正确的语句是
窗体上有一个名称为Command1的命令按钮,其单击事件过程及相关的函数过程如下:PrivateSubCommand1_Click()DimiAsIntegerFori=1To500Ifp(i)
(1)在名称为Form1的窗体上添加一个名称为Picture1的图片框(PictureBox),高、宽均为1000。在图片框内再添加一个有边框的名称为Imagel的图像框(Image)。并通过属性窗口把考生文件夹下的图标文件Pointl1(香蕉图标)装入图
在窗体上画一个通用对话框,其名称为CommonDialog1,则下列与Commonialog1.ShowOpen方法等效的语句是()。
若变量a未事先定义而直接使用(例如:a=0),则变量a的类型是( )。
下面能够将某个变量声明为局部变量的是
随机试题
试述外伤性前房积血的并发症及治疗。
A、艾迪生病B、侏儒症C、库欣综合征D、肢端肥大症E、性幼稚症性激素分泌不足可致
执行政府定价或者政府指导价的,在合同约定的交付期限内政府价格调整时,()。
用高级语言来编写的程序()。
下列各项中,( )不属于个人贷款抵押房屋保险的保险标的。
结合实际,谈谈怎样才能创建一个优秀的班集体。
下列有关法的特征的表述,哪项为正确的组合?()①公司章程对公司、股东、董事、监事、经理均有约束力,为人们提供了行为的标准,因而具有法的特征和效力②一位党的干部因受贿被判处刑罚,同时被开除党籍,这些都是法的实施方式的体现
梁朝简文帝诗云:“紫燕跃武,赤兔越空。”两句中赤兔指良马,紫燕亦指良马。李善注谢灵运诗云:“文帝自代还,有良马九匹,一名飞燕骝。”在古代,武威铜马足下的飞燕无疑是用来比喻良马之神速。这种造型让人一看便知其意,所以铜马应直截了当取名为“紫燕骝”或“飞燕骝”,
中央型腰椎间盘突出症和马尾神经瘤最有意义的鉴别方法是
Whenaneight-lanesteel-truss-archbridgeacrosstheMississippiRiverinMinneapoliscollapsedduringtheeveningrushhouron
最新回复
(
0
)