首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
注意:下面出现的“考生文件夹”均为c:\wexam\25160001。 在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不
注意:下面出现的“考生文件夹”均为c:\wexam\25160001。 在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不
admin
2009-02-25
12
问题
注意:下面出现的“考生文件夹”均为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全国计算机二级
相关试题推荐
Java语言中最基本的输入输出流类是()。Ⅰ:InputStreamⅡ:OutputStreamⅢ:WriterⅣ:ReaderⅤ:BufferReaderⅥ:BufferWriter
下面各选项中正确的是()。Ⅰ:longl=4990Ⅱ:inti=4LⅢ:floatf=1.1Ⅳ:doubled=34
对如下二叉树进行后序遍历的结果为
2.【】的任务是诊断和改正程序中的错误。
在读取二进制数据文件的记录时,为了提高效率常常使用一种辅助类
下列关于Java对import语句规定的叙述中,错误的是
Java虚拟机中的______模块既负责管理针对各种类型数据库软件的JDBC驱动程序,也负责和用户的应用程序交互,为Java应用程序建立起基于JDBC机制的数据库连接。()
关系中的属性或属性组合,其值能够唯一地标识一个元组,该属性或属性组合可选做为【】。
输入输出在计算机中有两个主要作用,是【】和提供数据处理结果。
随机试题
根据下列材料回答问题。经过50多年的发展,我国台湾地区资本市场建立起由“证券交易所集中市场一上柜市场—兴柜市场”构成的完善成熟的多层次资本市场体系。近年由于金融海啸、欧债危机等因素影响,台湾多层次资本市场总体成交值从2010至2012年连续3年下降,20
早期的电影多是全景式的“纪录视角”,这是由于摄影机无法移动,只能________传统戏剧我演你看的观演关系。随着各种摄影新技术和剪辑新手法的出现,电影依靠独特的镜头语言,逐渐脱离戏剧的束缚,________。完全依据戏剧思维,使用单一固定的场景所打造的电影
甲状腺危象的治疗,首选药物是
正常阴道分泌物为
2004年底,华夏基金管理公司推出国内首只上市开放式基金——华夏上证50ETF。()
下列不属于商业银行流动性的基本要素的是()
关于国有土地上房屋征收的说法,错误的有()。
管理会计应用主体必须是单位内部的责任中心。()
这是一个发生在春天的故事,一个房间苏醒了。两扇窗扉,被一缕朝阳打开,眉目便____________________起来。风在窗外徐徐地吹,几只麻雀跳在枝尖——不,是跳在一封远方寄来的情书中,跳成一个逗号,一个句号,或者一串_________________
Islamiclawisaparticularlyinstructiveexampleof"sacredlaw".Islamiclawisaphenomenonsodifferentfromallotherforms
最新回复
(
0
)