首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
注意:下面出现的“考生文件夹”均为c:\wexam\25160001。 在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不
注意:下面出现的“考生文件夹”均为c:\wexam\25160001。 在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不
admin
2009-02-25
22
问题
注意:下面出现的“考生文件夹”均为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全国计算机二级
相关试题推荐
在一个有n个元素的顺序表的第i个元素(1≤i≤n)之前插入一个新元素时,需要向后移动【】个元素。
下面程序段是创建一个Date类的对象并把它串行化保存到文件中,该对象表示的是运行时刻的日期及时间,请将程序补充完整。importjava.util.*;imporjava.io.*;publicclassSerializeD
下列关于线性表叙述中不正确的是()。
关于文件名的处理中,测试当前文件是否目录用【】函数。
一个具体的线程是由上【】、代码和数据组成。
Java中用于提供Java语言、Java虚拟机的核心的类和接口的包是()。
Java源文件中最多只能有一个【】类,其他类的个数不限。
算法的空间复杂度是指()。
Mid(″HelloEveryone″,7,3)的执行结果是
随机试题
下列关于室内消火栓设备的安装要求中,说法错误的是()。
世界卫生组织全球性调查表明,全世界总人口中真正健康的人占()
初级口腔卫生保健的概念主要是全社区成员平等享有
根据我国《海商法》关于船舶物权问题的规定,下列表述哪些是正确的?
施工成本计划是确定和编制施工项目在计划期内的( )等的书面方案。
《中华人民共和国合同法》规定,当事人订立合同,应当具有()。
下列我国古代发明的生产工具中,按照用途划分,不同于其他各项的是()。
获得奥斯卡大奖的影片《泰坦尼克号》在滨州上映,滨州独家经营权给了滨州电影发行放映公司。公司各部门可忙坏了,宣传部投入了史无前例的170万元进行各种形式的宣传,业务部组织了8家大影院超前放映和加长档期,财务部具体实施与各影院的收入分账,最终几乎全市的老百姓都
求二元函数f(x,Y)=x3一3x2一9x+y2一2y+2的极值.
下列关于软件质量模型的说法中正确的是______。A)外部质量是表征软件产品在规定条件下使用时,决定其满足规定的和隐含的要求的能力B)容错性,通用性,结构性和通信性不全属于软件的质量特性C)内部质量是表征软件产品在规定条件下使用时,满足规定的和
最新回复
(
0
)