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

上传人:tireattitude366 文档编号:1327612 上传时间:2019-10-17 格式:DOC 页数:3 大小:31.50KB
下载 相关 举报
【计算机类职业资格】二级VISUAL+BASIC机试-84及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】二级VISUAL+BASIC机试-84及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】二级VISUAL+BASIC机试-84及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、二级 VISUAL+BASIC 机试-84 及答案解析(总分:100.00,做题时间:90 分钟)1.在窗体上创建两个单选按钮,名称分别为 Option1 和 Option2,标题分别为“100 到 300 之间的质数”和“200 到 400 之间的质数”,以及一个文本框,名称为 Text1。在窗体上创建两个命令按钮,名称分别为 Command1 和 Command2,标题分别为 “计算”和“保存数据”。编写事件过程,程序运行后,单击“计算”按钮,则计算出该单选按钮标题所指明的所有质数之和,并在文本框中输出。单击“保存数据”,存入 out.txt 文件中,该文件必须放在考生文件夹中(在考生文件

2、夹中有标准模块 module1.bas,其中的savedata 过程可以把计算结果写入指定文件,用 check 函数可以判断某整数是否为质数,是则返回True,否则返回 False。)程序运行界面如图 30 所示。要求实现题目给出的功能,并将文件保存在考生文件夹下,工程文件名为 ylc.vbp。(分数:100.00)_二级 VISUAL+BASIC 机试-84 答案解析(总分:100.00,做题时间:90 分钟)1.在窗体上创建两个单选按钮,名称分别为 Option1 和 Option2,标题分别为“100 到 300 之间的质数”和“200 到 400 之间的质数”,以及一个文本框,名称为

3、Text1。在窗体上创建两个命令按钮,名称分别为 Command1 和 Command2,标题分别为 “计算”和“保存数据”。编写事件过程,程序运行后,单击“计算”按钮,则计算出该单选按钮标题所指明的所有质数之和,并在文本框中输出。单击“保存数据”,存入 out.txt 文件中,该文件必须放在考生文件夹中(在考生文件夹中有标准模块 module1.bas,其中的savedata 过程可以把计算结果写入指定文件,用 check 函数可以判断某整数是否为质数,是则返回True,否则返回 False。)程序运行界面如图 30 所示。要求实现题目给出的功能,并将文件保存在考生文件夹下,工程文件名为 y

4、lc.vbp。(分数:100.00)_正确答案:(1)Visual Basic 集成环境中,执行“文件”“打开工程”命令,选择 ylc.vbp 文件打开。(2)执行“工程”“添加模块”命令,在“打开模块”对话框中,打开“标准模块” modulel.bas。(3)在工具箱中选择单选按钮控件,在窗体上创建两个单选按钮,名称分别为 Option1 和 Option2,标题分别为“100 到 300 之间的质数”和“200 到 400 之间的质数”。(4)在窗体上创建命令按钮名称分别为 Command1 和 Command2,标题分别为“计算”和“存盘”。(5)定义模块级数组,在模块的声明段声明,其代

5、码如下:Dim a(1 To 100) As IntegerDim count As Integer(6)双击“计算”按钮,弹出代码窗口,在其中添加如下代码:Dim count As IntegerPrivate Sub Command1_Click()Dim i As IntegerIf Optionl,Value ThenFor i=100 To 300If module1.check(i) Thencount=count+iEnd IfNext iElseFor i=200 To 400If module1.check(i) Thencount=count+iEnd IfNext iEn

6、d IfText1.Text=countEnd Sub(7)调用 savedata 过程,把文件中的数值读到指定的数组中保存事件。其代码如下:Private Sub Command2_Click()Dim str As Integerstr=CStr(count)Call module1.SaveData(“out.txt“, count)End Sub(8)双击“保存数据”按钮弹出代码窗口,在其中添加如下代码:Private Sub Command3_Click()Call SaveData(Text1.Text)End SubSub SaveData(str As String)Open app.Path & “/“&“out.txt“For Output As #1Print countClose#1End Sub(9)按 F5 键运行程序。如图 30 所示。(10)执行“文件”一“保存工程”命令,将工程文件命名为 ylc.vbp,窗体文件命名为 ylc.frm。)解析:解析 (1)本题是一个综合应用题,根据题目的要求添加模块、创建单选按钮、命令按钮及文本框,并设置其属性。(2)在命令按钮的单击事件中,调用模块中的函数过程,判断质数,并累计某段区间的质数总和。在文本框中输出结果,并将该结果写入指定文件中。

展开阅读全文
相关资源
猜你喜欢
  • GOST R 8 867-2014 State system for ensuring the uniformity of measurement Measuring instruments of direct current in range from 1·10 v stepeni -15 to 1·10 v stepeni -9 A Verificati.pdf GOST R 8 867-2014 State system for ensuring the uniformity of measurement Measuring instruments of direct current in range from 1·10 v stepeni -15 to 1·10 v stepeni -9 A Verificati.pdf
  • GOST R 8 869-2014 State system for ensuring the uniformity of measurements State verification schedule for means measuring electron paramagnetic resonance spectrum parameters《确保测量一.pdf GOST R 8 869-2014 State system for ensuring the uniformity of measurements State verification schedule for means measuring electron paramagnetic resonance spectrum parameters《确保测量一.pdf
  • GOST R 8 870-2014 State system for ensuring the uniformity of measurements State verification schedule for instruments measuring of sound velocity in liquids within the velocity ra.pdf GOST R 8 870-2014 State system for ensuring the uniformity of measurements State verification schedule for instruments measuring of sound velocity in liquids within the velocity ra.pdf
  • GOST R 8 871-2014 State system for ensuring the uniformity of measurements In house reference materials reference materials of the branches The general requirements《 确保测量一致性的国家系统 内.pdf GOST R 8 871-2014 State system for ensuring the uniformity of measurements In house reference materials reference materials of the branches The general requirements《 确保测量一致性的国家系统 内.pdf
  • GOST R 8 873-2014 State system for ensuring the uniformity of measurements State verification schedule for provided with measuring functions technical systems and devices accomplishe d.pdf GOST R 8 873-2014 State system for ensuring the uniformity of measurements State verification schedule for provided with measuring functions technical systems and devices accomplishe d.pdf
  • GOST R 8 874-2014 State system for ensuring the uniformity of measurements Autocollimators Verification procedure《确保测量一致性的国家系统 自动准直仪 验证程序》.pdf GOST R 8 874-2014 State system for ensuring the uniformity of measurements Autocollimators Verification procedure《确保测量一致性的国家系统 自动准直仪 验证程序》.pdf
  • GOST R 8 875-2014 State system for ensuring the uniformity of measurements State verification schedule for measuring instruments of the phase shift angle between two electric signao 65.pdf GOST R 8 875-2014 State system for ensuring the uniformity of measurements State verification schedule for measuring instruments of the phase shift angle between two electric signao 65.pdf
  • GOST R 8 876-2014 State system for ensuring the uniformity of measurements Theodolites Verification procedure《确保测量一致性的国家系统 经纬仪 验证程序》.pdf GOST R 8 876-2014 State system for ensuring the uniformity of measurements Theodolites Verification procedure《确保测量一致性的国家系统 经纬仪 验证程序》.pdf
  • GOST R 8 878-2014 State system for ensuring the uniformity of measurements Nuclear material control and accounting System of measurements Estimation of uncertainty in the sampling《.pdf GOST R 8 878-2014 State system for ensuring the uniformity of measurements Nuclear material control and accounting System of measurements Estimation of uncertainty in the sampling《.pdf
  • 相关搜索

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

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