【计算机类职业资格】二级VISUAL+BASIC机试-58及答案解析.doc

上传人:rimleave225 文档编号:1327592 上传时间:2019-10-17 格式:DOC 页数:6 大小:42KB
下载 相关 举报
【计算机类职业资格】二级VISUAL+BASIC机试-58及答案解析.doc_第1页
第1页 / 共6页
【计算机类职业资格】二级VISUAL+BASIC机试-58及答案解析.doc_第2页
第2页 / 共6页
【计算机类职业资格】二级VISUAL+BASIC机试-58及答案解析.doc_第3页
第3页 / 共6页
【计算机类职业资格】二级VISUAL+BASIC机试-58及答案解析.doc_第4页
第4页 / 共6页
【计算机类职业资格】二级VISUAL+BASIC机试-58及答案解析.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、二级 VISUAL+BASIC 机试-58 及答案解析(总分:100.00,做题时间:90 分钟)一、1 基本操作题(总题数:1,分数:30.00)1.注意:下面出现的“”均为 c:/wexam/25160001。请根据以下各小题的要求设计 Visual Basic 应用程序(包括界面和代码)。(1)在名称为 Form1 的窗体上建立一个名称为 Text1 的文本框,一个名称为 Cmd1,标题为“输出”的命令按钮,如图 4-1 所示。要求程序运行后,在文本框输入几个字符,单击“输出”按钮,则在窗体上显示文本框中的文字。注意:在程序中不能使用任何变量。保存时必须存放在考生文件夹下,窗体文件名为

2、sjt1.frm,工程文件名为 sjt1.vbp。(2)在名称为 Form1 的窗体上建立两个名称分别为 Cmd1 和 Cmd2,标题为“按钮一”和“按钮二”的命令按钮,如图 4-2 所示。要求程序运行后,如果单击“按钮一”,则把“按钮二”移到“按钮一”上,使两个按钮重合,如图 4-3 所示。注意:在程序中不得使用任何变量(必须通过属性设置来移动控件)。保存时必须存放在考生文件夹下,窗体文件名为 sjt2.frm,工程文件名为 sjt2.vbp(分数:30.00)_二、2 简单应用题(总题数:1,分数:40.00)2. (分数:40.00)_三、3 综合应用题(总题数:1,分数:30.00)3

3、 (分数:30.00)_二级 VISUAL+BASIC 机试-58 答案解析(总分:100.00,做题时间:90 分钟)一、1 基本操作题(总题数:1,分数:30.00)1.注意:下面出现的“”均为 c:/wexam/25160001。请根据以下各小题的要求设计 Visual Basic 应用程序(包括界面和代码)。(1)在名称为 Form1 的窗体上建立一个名称为 Text1 的文本框,一个名称为 Cmd1,标题为“输出”的命令按钮,如图 4-1 所示。要求程序运行后,在文本框输入几个字符,单击“输出”按钮,则在窗体上显示文本框中的文字。注意:在程序中不能使用任何变量。保存时必须存放在考生

4、文件夹下,窗体文件名为 sjt1.frm,工程文件名为 sjt1.vbp。(2)在名称为 Form1 的窗体上建立两个名称分别为 Cmd1 和 Cmd2,标题为“按钮一”和“按钮二”的命令按钮,如图 4-2 所示。要求程序运行后,如果单击“按钮一”,则把“按钮二”移到“按钮一”上,使两个按钮重合,如图 4-3 所示。注意:在程序中不得使用任何变量(必须通过属性设置来移动控件)。保存时必须存放在考生文件夹下,窗体文件名为 sjt2.frm,工程文件名为 sjt2.vbp(分数:30.00)_正确答案:(解析在窗体上建立好控件后,先设置控件属性,再编写事件过程。通过命令按钮的 Caption 属性

5、来设置其标题,单击命令按钮触发 Click 事件;文本框显示内容是用 Text属性。文本框中的内容通过其 Text 属性得到,在命令按钮的 Click 事件中利用 Print 方法将文本框中的内容输出,完成题目要求。解题步骤:第一步:建立界面并设置控件属性。程序中用到的控件及其属性见表 4-1。*第二步:编写程序代码。参考代码:Private Sub Cmd1_Click()ClsPrint Text1.TextEnd Sub第三步:调试并运行程序。第四步:按题目要求存盘。(2)解析在窗体上建立好控件后,先设置控件的属性,再编写事件过程。命令按钮的 Caption 属性用来设置其标题,单击命令

6、按钮触发 Click 事件,本题考查的是按钮的摆放位置的设置,涉及到对象的 Left 和 Top 属性。Left 表示控件与所在窗体的左边之间的距离,Top 表示控件与所在窗体的顶边之间的距离。让两个按钮位置重合只需将两个按钮的 Left 和 Top 设置相同即可。解题步骤:第一步:建立界面并设置控件属性。程序中用到的控件及其属性见表 4-2。*第二步:编写程序代码。参考代码:Private Sub Cmd1_Click()Cmd2.Left = Cmd1.LeftCmd2.Top = Cmd1.TopEnd Sub第三步:调试并运行程序。第四步:按题目要求存盘。答案考生文件夹)解析:二、2

7、简单应用题(总题数:1,分数:40.00)2. (分数:40.00)_正确答案:(解析在窗体上建立好控件后,先设置控件属性,再编写事件过程。要使文本框中的字符用于算术运算,首先要利用 Val 将文本框中输入的数字字符转换为数字类型(文本框中的内容默认为字符串类型)。解题步骤:第一步:建立界面并设置控件属性。第二步:编写程序代码。程序提供的代码:Option ExplicitPrivate Sub C1_Click()Dim i As Integer,s As IntegerDim a As Integer,b As Integera = Val(Text1.Text)b = Val(Text2

8、Text)If ab Theni = aa = b b = ?End Ifs = 0For i = a To b s = s + ?Next iText3.Text = sEnd Sub参考代码:Option ExplicitPrivate Sub C1_Click()Dim i As Integer, s As IntegerDim a As Integer, b As Integera = Val(Text1.Text)b = Val(Text2.Text)If a b Theni = aa = bb = iEnd Ifs = 0For i = a To bs = s + iNext i

9、Text3.Text = sEnd Sub第三步:调试并运行程序。第四步:按题目要求存盘。(2)解析在窗体上建立好控件后,先设置控件的属性,再编写事件过程。命令按钮的 Caption 属性用来设置其标题,单击命令按钮触发 Click 事件:在文本框中显示内容通过其Text 属性来设置。解题步骤:第一步:建立界面并设置控件属性。程序中用到的控件及其属性见表 4-3。*第二步:编写程序代码。标准模块代码:Option ExplicitSub putdata(t_FileName As String,t_Str As Variant)Dim SFile As StringSFile =“/“ Nex

10、tClose #1End Sub窗体代码:Option ExplicitDim i(1 To 100) As IntegerPrivate Sub Cmd1_Click()Dim j As IntegerOpen “in.txt“ For Input As #1For j = 1 To 100 ? #1, i(j)Text1.Text = Text1.Text & i(j) & Space(5)NextClose #1End SubPrivate Sub Cmd2_Click()Dim j As IntegerDim k As IntegerDim temp As IntegerDim fla

11、g As BooleanFor j = 1 To 100flag = ?For k = 1 To 100 - jIf i(k) i(k + 1) Thentemp = i (k)i(k) = i(k + 1)i(k + 1) = tempflag = TrueEnd IfNextIf Not flag ThenExit ForEnd IfNextText1.? = “For j = 1 To 100Text1.Text = Text1.Text & i(j) & Space(5)Nextputdata i, 100End Sub参考代码:Option ExplicitDim i(1 To 10

12、0) As IntegerPrivate Sub Cmd1_Click()Dim j As IntegerOpen “in.txt“ For Input As #1For j = 1 To 100Input #1, i(j)Text1.Text = Text1.Text & i(j & Space(5)NextClose #1End SubPrivate Sub Cmd2_Click()Dim j As IntegerDim k As IntegerDim temp As IntegerDim flag As BooleanFor j = 1 To 100flag = FalseFor k = 1 To 100 - jIf i(k) i(k + 1) Thentemp = i (k)i(k) = i(k + 1)i(k + 1) = tempflag = TrueEnd IfNextIf Not flag ThenExit ForEnd IfNextText1.Text = “For j = 1 To 100Text1.Text = Text1.Text & i(j) & Space(5)Nextputdata i, 100End Sub第三步:调度并运行程序。第四步:按题目要求存盘。)解析:

展开阅读全文
相关资源
猜你喜欢
  • GOST R 50030 4 1-2012 Low-voltage switchgear and controlgear Part 4 Contactors and motor-starters Section 1 Electromechanical contactors and motor-starters《低压开关装置和控制装置 第4-1部分 电流接触器.pdf GOST R 50030 4 1-2012 Low-voltage switchgear and controlgear Part 4 Contactors and motor-starters Section 1 Electromechanical contactors and motor-starters《低压开关装置和控制装置 第4-1部分 电流接触器.pdf
  • GOST R 50030 4 2-2012 Low-voltage switchgear and controlgear Part 4 Contactors and motor-starters Section 2 AC semiconductor motor controllers and starters《低压开关装置和控制装置 第4-2部分 电流接触器.pdf GOST R 50030 4 2-2012 Low-voltage switchgear and controlgear Part 4 Contactors and motor-starters Section 2 AC semiconductor motor controllers and starters《低压开关装置和控制装置 第4-2部分 电流接触器.pdf
  • GOST R 50030 5 2-1999 Low-voltage switchgear and controlgear Part 5-2 Control circuit devices and switching element Proximity switches《低压开关设备和控制设备 第5-2部分 控制电路装置和开关元件 接近开关》.pdf GOST R 50030 5 2-1999 Low-voltage switchgear and controlgear Part 5-2 Control circuit devices and switching element Proximity switches《低压开关设备和控制设备 第5-2部分 控制电路装置和开关元件 接近开关》.pdf
  • GOST R 50030 5 4-2011 Low-voltage switchgear and controlgear Part 5-4 Control circuit devices and switching elements Method of assessing the performance of low-energy contacts Spec.pdf GOST R 50030 5 4-2011 Low-voltage switchgear and controlgear Part 5-4 Control circuit devices and switching elements Method of assessing the performance of low-energy contacts Spec.pdf
  • GOST R 50030 5 8-2013 Low-voltage switchgear and controlgear Part 5-8 Control circuit devices and switching elements Three-position enabling switches《低压开关设备和控制设备 第5-8部分 控制电路电器和开关元件.pdf GOST R 50030 5 8-2013 Low-voltage switchgear and controlgear Part 5-8 Control circuit devices and switching elements Three-position enabling switches《低压开关设备和控制设备 第5-8部分 控制电路电器和开关元件.pdf
  • GOST R 50030 6 2-2011 Low-voltage switchgear and controlgear Part 6-2 Multiple function equipment Control and protective switching devices (or equipment) (CPS)《低压开关设备和控制设备 第6-2部分 多.pdf GOST R 50030 6 2-2011 Low-voltage switchgear and controlgear Part 6-2 Multiple function equipment Control and protective switching devices (or equipment) (CPS)《低压开关设备和控制设备 第6-2部分 多.pdf
  • GOST R 50032-1992 Meal from fish marine mammals crustaceans and invertebrates Methods for determination of mass components of carbamid and calculation of fresh protein taking into .pdf GOST R 50032-1992 Meal from fish marine mammals crustaceans and invertebrates Methods for determination of mass components of carbamid and calculation of fresh protein taking into .pdf
  • GOST R 50034-1992 Electromagnetic compatibility Asynchronous motors of voltage about 1000 V Limits and test methods on immunity to electromagnetic disturbance《电磁兼容性 电压约为1000 V的异步电动.pdf GOST R 50034-1992 Electromagnetic compatibility Asynchronous motors of voltage about 1000 V Limits and test methods on immunity to electromagnetic disturbance《电磁兼容性 电压约为1000 V的异步电动.pdf
  • GOST R 50035-1992 Combined broaches with diameter from 50 to 120 mm for slitting holes with involute profile with wind round tail and centring at outside diameter with module from .pdf GOST R 50035-1992 Combined broaches with diameter from 50 to 120 mm for slitting holes with involute profile with wind round tail and centring at outside diameter with module from .pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1