首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
注意:下面出现的“考生文件夹”均为c:\wexam\25160001。 在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不
注意:下面出现的“考生文件夹”均为c:\wexam\25160001。 在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不
admin
2009-02-25
43
问题
注意:下面出现的“考生文件夹”均为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全国计算机二级
相关试题推荐
下面不属于软件设计原则的是
要从文件“file.dar”文件中读出第10个字节到变量C中,下列哪个方法适合()
下面ChangeTitle()中对b1和b2按钮构造监听器,实现当单击b1按钮时标题变为students,当单击b2按钮时标题变为teachers。请将程序补充完整。publicChangeTitle(){super("Title
要表示表格的数据,需要继承类()。
如下程序的输出结果是()。publicclassTest{voidprintValue(intm){do{System.out.println("Theval
在编写Java程序的时候,如果不为类的成员变量定义初始值,Java会给它们设置默认值,下列说法中不正确的是()。
Java语言中如果要使用某个包中的类时,需要使用上【】导入。
数据库DB、数据库系统DBS、数据库管理系统DBMS之间的关系是
软件调试的目的是
一个向量第1个元素的存储地址是100,每个元素的长度为2,则第5个元素的地址是()。
随机试题
高频探头(7.5MHz)其()。
下列抗高血压药物中,最易引起体位性低血压的药物是
牙周炎患者经牙周基础治疗后
对诊断精神分裂症最有意义的一组症状是
建设划拨用地规划管理审核的内容中,城乡规划主管部门受理建设用地申请后,应依据控制性详细规划对建设用地提出规划条件,该条件内容应包括()
新华网报道,国家工商行政管理总局将负责组织、指导、协调和督办跨省广告违法案件的查处工作,直接或参与办理全国性重大违法虚假广告案件。这是中国系列打击欺诈犯罪的一个环节,事实上,从食品案例到股票市场内幕交易,正在建立反欺诈的系列攻势。我们已经看到在毒胶囊等事件
给定资料资料1下面是某网站最近发表的谈关于公共文化教育的文字:当前,在经济高速发展的同时,许多城市出现了一系列问题,城市生命线似乎脆弱得不堪一击。一场不太大的雨雪就能让城市半瘫痪,居民的家也不再是安全的港湾,劣质建材散发着致癌的毒气,劣
Whatdoesitmeantobeintelligent?Mostpsychologistsagreethatabstractreasoning,problemsolving,andtheabilitytoacqui
窗体中的数据来源主要包括表和【】。
A、Hehashadthirteendecayedteeth.B、Hedoesn’thaveasingledecayedtooth.C、Hehasfewerdecayedteeththanotherpeopleof
最新回复
(
0
)