首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
注意:下面出现的“考生文件夹”均为c:\wexam\25160001。 在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不
注意:下面出现的“考生文件夹”均为c:\wexam\25160001。 在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不
admin
2009-02-25
27
问题
注意:下面出现的“考生文件夹”均为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://www.kaotiyun.com/show/GQ1p777K
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
将整个软件划分成若干单独命名和可编址的部分,称之为【】。
下面程序段是创建一个Date类的对象并把它串行化保存到文件中,该对象表示的是运行时刻的日期及时间,请将程序补充完整。importjava.util.*;imporjava.io.*;publicclassSerializeD
如果有一个类MyFrame是Frame的子类,但它不能被实例化,请写出该类的声明头: 【】 。
Jackson方法是一种面向【】的结构化方法。
执行下面的程序段,输出结果为【】publicclassQ{publicstaticvoidmain(Stringargv[]{intanar[]=newint[5];System.out.pr
向DataOutputStream对象dos的当前位置处写入一个保存在变量f中的浮点数的语句是【】。
下列关于异常类型的说明中错误的是()。
算法的有穷性是指
已知有定义:Strings="story",下面哪一个表达式是合法的?()
如果对一个关系实施了一种关系运算后得到了一个新的关系,而且新的关系中属性个数少于原来关系中属性个数,这说明所实施的运算关系是()。
随机试题
当产品需求价格弹性为一1.5时,成本加成率为()
主诉的含义是()
白虎汤主治病证中的主症是泻白散主治病证中的主症是
患者,女,40岁。呕吐清水,胃部不适,食久乃吐,喜热畏寒,身倦,便溏,小便可,舌苔白,脉迟。治疗除取主穴外,还应加
在计算项目投资的经营成本时,需要考虑筹资方案的影响。()
【2014年山东济宁.单选】马斯洛需求层次理论说明在某种程度上学生缺乏学习动机,可能是由于某种()需要没有得到充分满足而引起的。
习近平总书记在中央扶贫开发工作会议上强调,消除贫困、改善民生、逐步实现共同富裕,是社会主义的本质要求,是我们党的重要使命。全面建成小康社会,是我们对全国人民的庄严承诺。脱贫攻坚战的冲锋号已经吹响。我们要立下愚公移山志,咬定目标、苦干实干,坚决打赢脱贫攻坚战
根据以下资料,回答下列问题。2012年北京地区外贸进出口规模达到4079亿美元,比2011年增长4.7%。其中,出口596亿美元,同比增长1.1%;进口3483亿美元,同比增长5.3%。2012年北京地区文化产品进出口6亿美元,同比增长6.3%。其中,
[2018年]设平面区域D由曲线与直线及y轴围成,计算二重积分
Hurricane(飓风)KatrinaAhurricaneisafiercelypowerful,rotating(旋转的)formoftropicalstormthatcanbe124to1,240mile
最新回复
(
0
)