首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
注意:下面出现的“考生文件夹”均为c:\wexam\25160001。 在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不
注意:下面出现的“考生文件夹”均为c:\wexam\25160001。 在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不
admin
2009-02-25
25
问题
注意:下面出现的“考生文件夹”均为c:\wexam\25160001。
在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不得改变文件名和文件夹。如图17-5所示。
在名称为Form1,标题为“分苹果”的窗体上,有名称为Frame1,标题为“分苹果大赛”的一个Frame控件。其中包括4个Picture控件、4个Labe1控件和4个 Command控件。具体如下:
PicSmile(0)~(1)为Tom和Marry的笑脸图案,PicCry(0)~(1)为哭脸图案;PicSmile(0)和PicCry(0)重叠,PicSmile(1)和 PicCry(1)重叠。按Command1(0)和Command1(1)时,Labe1(0)和labe1(1)减少。当Labe1(0)或Labe1(1)的值为零时,相对应的 Command按钮失效(变灰);按Command2(0)和Command1(1)时,Labe1(0)和Labe1(1)增加。程序启动时两人均为笑脸。两人当中所分苹果比较多的呈现笑脸,另一个是哭脸;如果两人的苹果一样多,则两人都为笑脸。
选项
答案
在窗体上建立好控件后,先设置控件属性,再编写事件过程。 控件数组是由一组相同类型的控件组成,建立控件数组时系统给每个元素赋一个惟一的索引号(Index),控件数组 cmdName(3)表示控件数组名为cmdName的第4个元素;利用其下标号可选择不同的控件数组元素,如:控件是否可用由其Enabled属性决定,当该属性值为True时可用,为False时不可用(灰色);控件是否可见由其Visible属性决定,该值为 True时,控件可见,为False时控件不可见。解题步骤: 第一步:建立界面并设置控件属性。程序中用到的控件及其属性见表17-5。 [*] 第二步:编写程序代码。 程序提供的代码: Option Explicit Private Sub Command1_Click(Index As Integer) If Index=0 Then If Val(Label3(0) .Caption)>1 Then Command1 (0) .Enabled=True Label3(0) .Caption=Labe13(0) .Caption-1 Else If Val(Label3(0) .Caption)=1 Then Labe13(0) .Caption=Labe13(0) .Caption-1 End If ’Command1(0) .Enabled= End If Else If Val(Label3(1) .Caption)>1 Then Command1 (1) .Enabled=True Label3(1) .Caption=Label3(1) .Caption-1 Else If Val(Label3(1) .Caption)=1 Then Label3(1) .Caption=Label3(1) .Caption-1 End If Commandl(1) .Enabled=False End If End If ’If Val(Label3(0) .Caption) ? Val(Label3(1) .Caption) Then picSmile(0) .Visible=True picCry(0) .Visible=False picCry(1) .Visible=True picSmile(1) .Visible=False Else ’If Val(Label3(0) .Caption) ? Val(Label3(1) .Caption) Then picCry(0) .Visible=True picSmile(0) .Visible=False picSmile(1) .Visible=True picCry(1) .Visible= False Else picSmile(0) .Visible=True picCry(0) .Visible=False picSmile(1) .Visible=True picCry(1) .Visible=False End If End If End Sub Private Sub Command2_Click(Index As Integer) If Index=0 Then ’Label3(0) .Caption= Command1 (0) .Enabled=True Else: ’Label3(1) .Caption= Command1 (1) .Enabled=True End If ’If Val(Label3(0) .Caption) ? Val(Label3(1) .Caption) Then picSmile(0) .Visible=True picCry(0) .Visible=False picCry(1) .Visible=True picSmile(1) .Visible=False Else ’If Val(Label3(0) .Caption) ? Val(Label3(1) .Caption) Then picCry(0) .Visible=True picSmile(0) .Visible=False picSmile(1) .Visible=True picCry(1) .Visible=False Else picSmile(0) .Visible=True picCry(0) .Visible=False picSmile(1) .Visible=True picCry(1) .Visible=False End If End If End Sub Private Sub Form Load () PicSmile(0) .Visible=True picSmile(1) .Visible=True Command1(0) .Enabled=False Command1(1) .Enabled=False End Sub 参考代码: Option Explicit Private Sub Command1_Click(Index As Integer) If Index=0 Then If Val(Label3(0) .Caption)>1 Then Command1 (0) .Enabled=True Label3(0) .Caption=Label3(0) .Caption-1 Else If Val(Label3(0) .Caption)=1 Then Label3(0) .Caption=Label3(0) .Caption-1 End If Command1(0) .Enabled=False End If Else If Val(Label3(1) .Caption)>1 Then Command1(1) .Enabled=True Label3(1) .Caption=Label3(1) .Caption-1 Else If Val(Label3(1) .Caption)=1 Then Label3(1) .Caption=Label3(1) .Caption-1 End If Command1(1) .Enabled=False End If End If If Val(Label3(0) .Caption)>Val(Label3(1) .Caption) Then picSmile(0) .Visible=True picCry(0) .Visible=False picCry(1) .Visible=True picSmile(1) .Visible=False Else If Val(Label3(0) .Caption)<Val(Label3(1) .Caption) Then picCry(0) .Visible=True picSmile(0) .Visible=False picSmile(1) .Visible=True picCry(1) .Visible=False Else picSmile(0) .Visible=True picCry(0) .Visible=False picSmile(1) .Visible=True picCry(1) .Visible=False End If End If End Sub Private Sub Command2_Click(Index As Integer) If Index=0 Then Label3(0) .Caption=Label3(0) .Caption+1 Command1 (0) .Enabled=True Else: Label3(1) .Caption=Label3(1) .Caption+1 Commandl (1) .Enabled=True End If If Val(Label3(0) .Caption) > Val(Label3(1) .Caption) Then picSmile(0) .Visible = True picCry(0) .Visible = False picCry(1) .Visible = True picSmile(1) .Visible = False Else If Val(Label3(0) .Caption)<Val(Label3(1).Caption) Then picCry(0) .Visible=True picSmile(0) .Visible=False picSmiie(1) .Visible=True picCry(1) .Visible=False Else picSmile(0) .Visible=True picCry(0) .Visible=False picSmile(1) .Visible=True picCry(1) .Visible=False End If End If End Sub Private Sub Form Load() picSmile(0) .Visible=True picSmile(1) .Visible=True Command1(0) .Enabled=False Command1(1) .Enabled=False End Sub 第三步:调试并运行程序。 第四步:按题目要求存盘。
解析
转载请注明原文地址:https://kaotiyun.com/show/GQ1p777K
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
下面的程序执行后,屏幕上显示的应是【】。publicclassExam{publicstaticvoidmain(String[])args){charchar1[]={’1’,’2’,’3
Java语言中,下列标识符错误的是()
下面程序段的输出结果是【】。publicclassTest{publicstaticvoidmain(Stringargs[]){inti=1;switch(i){case
请指出在顺序表{2、5、7、10、14、15、18、23、35、41、52}中,用二分法查找关键码12须做()次关键码比较。
对如下二叉树进行后序遍历的结果为
在下列程序的下划线处,填入适当语句使程序能正确执行并输出异常栈信息。publicclassThrowableException{publicstaticvoidmain(Stringargs[]{tr
本题程序中实现了一个“生产者一消费者问题”。生产者产生一个随机数存入DataPool类中,消费者从中取出数据。DataPool类一次只能存放一个数据。请更正题中带下划线的部分。注意:不改变程序的结构,不得增行或删行。classDataPo
设x,y,max均为int型变量,x,y已赋值。用三目条件运算符求x,y的最大值,这个赋值语句应是max=【】。
在对一个复杂表达式进行运算时,要按运算符的优先顺序从高到低进行,同级的运算符则按照【】进行。
Mid("HelloEveryone",7,3)的执行结果是
随机试题
试述病种医疗质量管理的目的。
14个月女孩,稽留高热2周。咳嗽较剧,喘憋和发绀明显,左肺下部叩诊发浊,听诊呼吸音减弱,腹胀明显,肠鸣音消失,胸部X片:左肺下可见大片状阴影。白细胞5.3×10+/L,淋巴细胞0.77,根据病例诊断最大可能是
[背景资料]某水库溢洪道加固工程,控制段共3孔,每孔净宽8.0m,加固方案为:底板顶面增浇20cm厚混凝土,闸墩外包15cm厚混凝土,拆除重建排架、启闭机房、公路桥及下游消能防冲设施。溢洪道加固施工时,在铺盖上游填筑土围堰断流施工,围堰断面如图2F32
只有当货币资本与产业资本相分离,货币资本本身取得一种社会性质时,公司股票和债券等信用工具才会被充分运用。()
批准中央预算正式成立的机关是()。
下列说法中,正确的有()。
教育活动中要注意“三结合”,发挥教育合力。这“三结合”所指的是()
小张、小王、小李三位老师分别在学校教英语、语文、数学、物理、化学、历史,且每位老师教两门课。数学老师和英语老师同住一个宿舍,小李老师最年轻,数学老师和小张老师爱打篮球,小王老师比语文老师岁数大,比物理老师岁数小,三人中年纪中等的老师住得比其他两位老师远。由
在一定意义上,社会形态的更替过程是()
阅读材料,回答问题:材料1近段时间,网上出了个热词:“996”。这是一群程序员用来描述自己工作时间的词汇——每天工作从早9点到晚9点,一周工作6天。今年年初,有互联网公司公开宣布实施“996工作制”,结果被劳动监察部门及时制止。而近来。有媒体调查发现,
最新回复
(
0
)