Visual Basic程序设计—实验报告册-参考答案

合集下载

《Visual Basic程序设计教程》习题参考答案

《Visual Basic程序设计教程》习题参考答案

第1章习题一、选择题1. B2. A3. B4. A二、填空题1. 事件驱动或消息驱动2. 工程资源管理器、窗体三、问答题1. 11个菜单项。

文件菜单包括新建工程、打开工程、添加工程、移除工程、保存工程、工程另存为、保存窗体文件、窗体文件另存为、打印、打印设置、生成可执行文件等命令项;编辑菜单(命令项略,以下同)、视图菜单、工程菜单、格式菜单、调试菜单、运行菜单、查询菜单、图表菜单、工具菜单、外接程序菜单、窗口菜单、帮助菜单。

2. 可以自行定义。

标准工具栏中有添加工程、添加窗体、菜单编辑器、打开工程、保存工程、剪切、复制、粘贴、查找、撤销、恢复、启动、中断、结束、工程资源管理器、属性窗口、窗体布局窗口、对象浏览器、工具箱、数据视图窗口等按钮。

四、编程题(略)第2章习题一、选择题1. A二、练习题1. S1. 把x赋值给同类型变量t;S2. 把y赋值给x;S3. 把t赋值给y。

2. S1. 输入a、b、c;S2. 如果a<b,则交换a与b的数据;S3. 如果a<c,则交换a与c的数据;S4. 如果b<c,则交换b与c的数据;S5. 输出a、b、c。

3. S1. 输入整数N;S2. 给整数K赋值2;S3. 如果K大于N-1,则转S6;S4.如果N除以K 的余数为0,则转S7;S5. K加1再赋值给K,转S3.;S6. 如果K大于N-1,则N为素数;否则N不是素数。

4. S1. 输入整数N;S2. 将N赋值给K;S3. 给整数nx赋值0;S4. 计算nx乘以10加K除以10的余数,再赋值给nx;S5. 计算K除以10的整数商,赋值给K;S6. 如果K>0,则转S4;否则,转S7;S7. 如果N=nx,则N为回文数,否则N不是回文数。

5.6.第3章习题一、选择题1. D2. C3. A4. B5. D6. A7. B8. D9. B 10. D 11. A . 12. C 13. C 14. C二、填空题1. 标题、引用2. ②④⑤3. 64. GotFocus、Resize5. AddItem、Clear6. Label,CommandButton,OptionButton,CheckBox,Frame、TextBox,ListBox,ComboBox7. PictureBox,Frame8. OptionButton,CheckBox,HScrollBar,VScrollBar、OptionButton、CheckBox,HScrollBar,VScrollBar三、问答题1. 答:对象的只读属性的属性值(如名称属性)只能在设计界面时在属性窗口进行设置;非运行属性的属性值则既可在设计界面时在属性窗口进行设置,也可通过程序代码进行设置与修改。

visual_Basic程序设计教程_课后习题答案及练习

visual_Basic程序设计教程_课后习题答案及练习

第三章 VB基本语言
一、填空题
1、一般可以使用__________关键字声明常量。
2、______类型也称变体类型,是一种通用的、可变的数据类型,它可表示或存储任何一种
数据类型。
3、变量的声明分为两种方法:__________和____________。 4、在VB中,用___________________语句设定数组的下界,用_____________ 和__________________语句分别返回数组的上、下界。 5、在代码模块中加入Option Explicit的目的是 _____________________。 6、function aa (a1 as date,optional a2 as boolean) as single,写出optional 命令的作用__________________。 7、在VB中,我们用一个简单的______语句就能实现退出程序。 8、生成消息框的命令是____________,生成输入框的命令是 ____________。 9、通用对话框(commondialog)属activex控件,它可以显示多个标准 对话框,包括打开/另存为、字体、打印等对话框,若要显示所有文 件,则应设置其属性filter=____________,若要使它显示为打印对话 框,则应使用什么方法____________。 10、从字符串中任意位置截取字符的函数是__________。 11、语句For j = 3 To 20 Step 3 使循环体执行了______次。 12、对于正在使用的动态数组Arraya(),要增加一个单元,但不能破坏数组内的数据,则应
二、选择题
1、下面不是VB工作模式的是( ) A.设计模式 B.运行模式 C.汇编模式 D.中断模式 2、可视化编程的最大优点是( ) A.具有标准工具箱 B.一个工程文件由若干个窗体文件组成 C.不需要编写大量代码来描述图形对象 D.所见即所得 3、下列不能打开属性窗口的操作是( ) A.执行“视图”菜单中的“属性窗口”命令 B.按F4键 C.按Ctrl+T D.单击工具栏上的“属性窗口”按钮 4、下列可以打开立即窗口的操作是( ) A.Ctrl+D B.Ctrl+E C.Ctrl+F D.Ctrl+G 5、Visual Basic的编程机制是( ) A.可视化 B.面向对象 C.面向图形 D.事件驱动

实验报告簿(程序设计基础VB答案)

实验报告簿(程序设计基础VB答案)

实验日期_____________________实验名称:实验一常用标准控件一【实验目的与要求】1.掌握Visual Basic的启动与退出。

2.熟悉Visual Basic的集成开发环境。

3.掌握在窗体中放置控件的方法。

4.掌握在“属性窗口”中设置控件属性的方法。

5.掌握在“代码编辑器”窗口中输入程序代码的方法。

6.掌握工具栏上启动按钮、结束按钮的使用方法。

7.掌握标签、文本框、命令按钮、列表框等控件的使用方法。

【实验内容与步骤】实验1.1.1 标签的使用(一)1.题目与要求:在名称为Form1、标题为“标签”的窗体上画一个名称为Label1的标签,并设置适当属性以满足以下要求:1)标签的内容为“计算机等级考试”;2)标签可根据显示内容自动调整其大小;3)标签带有边框,且标签内容显示为三号字。

2.实验步骤1)界面设置:在名称为Form1的窗体上放置一个标签控件Label1;2)属性设置(请将表格补充完整)表1.1.1 对象属性3)保存文件:存盘时必须存放在C:\VB\Sy01文件夹下,工程文件名为sjt1.vbp,窗体文件名为sjt1.frm。

实验1.1.2 标签的使用(二)1.在名称为Form1的窗体上画一个名称为 Label1的标签,标签的宽和高分别为2000、300,有边框,并利用属性窗口设置适当的属性,使其居中显示“等级考试”,并使标签的外观如图所示。

2.属性设置(请将表格补充完整)表1.1.2 对象属性sjt2.frm。

实验1.1.3 文本框的使用1.题目与要求:在名称为Form1的窗体上画两个文本框,名称分别为T1、T2,初始情况下都没有内容。

请编写适当的事件过程,使得在运行时,在T1中输入的任何字符,立即显示在T2中。

程序中不得使用任何变量。

2.实验步骤1)界面设置:在名称为Form1的窗体上放置两个文本框;2)属性设置3)完善程序代码Private Sub T1_Change()T2.Text=T1.Text (T2=T1)End Sub3)保存文件:存盘时必须存放在C:\VB\Sy01文件夹下,工程文件名为sjt3.vbp,窗体文件名为sjt3.frm。

visualbasic程序设计课后习题参考答案

visualbasic程序设计课后习题参考答案

Visual basic 程序设计习题参考答案第一章Visual basic 程序设计一、选择题3二、填空题三、简答题1、简述visual basic 的特点。

(1)具有可视化的设计平台(2)面向对象的设计方法(3)事件驱动的编程机制(4)结构化程序设计语言(5)开放的数据库功能与网络支持2、什么是对象、类、属性、事件和方法?在可视化编程语言中,对象是代码和数据的集合,它可以是窗体和控件,也可以是菜单和数据库等。

描述一个对象有三个基本要素:属性、方法和事件。

类是一组用来定义对象的相关过程和数据的集合,即同类对象的集合和抽象。

属性是描述对象的一组特性。

方法是对象能够执行的动作,它是对象本身内含的函数或过程,用于完成某种特定的功能。

事件是发生在对象上并且能够被对象识别的动作,即由系统预先设置好的、能被对象识别的动作,如Click(单击)、DblClick(双击)、Load(窗体的装载)、KeyPress(按键)、Change(改变)、MouseMove (鼠标的移动)等,每一种对象能识别的事件是不同的5、什么是事件驱动的编程机制?当某个事件(一般由用户操作来触发) 发生时,系统就会自动执行此事件的事件过程。

由事件控制整个程序的执行流程。

事件过程要经过事件的触发才能被执行,这种工作模式称为事件驱动方式。

第二章 Visual basic 程序设计基础一、选择题二、填空题第三章数据输入输出一、选择题二、填空题第四章选择结构和循环结构程序设计一、选择题二、填空题第五章数组一、选择题二、填空题第六章过程一、选择题二、填空题三、简答题1、简述事件过程和通用过程的含义和XXX。

VB应用程序是由过程组成的,过程是完成某种特殊功能的一组独立的程序代码。

VB中的过程有两大类:事件过程和通用过程事件过程是当发生某个事件时,对该事件作出响应的程序段。

事件过程由VB自行声明,用户不能增加或删除。

事件过程是VB应用程序的主体。

VB实验及答案

VB实验及答案

对象名称
属性名称
Form1
Caption
Command1 Caption
Label1
Caption
Label2
Caption
Label3
Caption
Text1、Text2 Text
属性值 象限判断 判断 X= Y=
(3)编写事件代码: Private Sub Command1_Click() Dim x!, y!
Private Sub Command2_Click() Dim f!, c! c = Val(Text2.Text) f = 9 / 5 * c + 32 Text1 = Str(f)
End Sub
(4)程序的运行及保存。 4 求圆的面积及圆柱体的体积,界面如图 2-3 所示。
【步骤】 (1)设计应用程序的界面:在窗体上创建两个命令按钮 Command1 和 Command2,四个标签 Label1、Label2、Label3 和 Label4,四个文本框 Text1、Text2、Text3 和 Text4。 (2)设置对象的属性
【步骤】
( 1 ) 在 窗 体 中 创 建 一 个 标 签 Label1 、 一 个 命 令 按 钮 Command1。
(2)在属性窗口中设置对象的属性:
对象名称
属性名称
属性值
Form1
Caption
设计界面
Label1
Caption
请留意此处
Command1
Caption
单击此处
(3)在 Command1 的 Click 事件中编写程序代码:
x = Val(Text1) y = Val(Text2) If x > 0 Then

VB实验参考答案

VB实验参考答案

VB实验参考答案VB实验参考答案VB(Visual Basic)是一种常用的编程语言,广泛应用于软件开发领域。

在学习VB的过程中,进行实验是非常重要的一部分。

本文将为大家提供一些VB实验的参考答案,帮助大家更好地理解和掌握VB编程。

实验一:简单的计算器程序要求:编写一个简单的计算器程序,能够实现基本的加减乘除运算。

参考答案:```vbPrivate Sub btnCalculate_Click()Dim num1 As DoubleDim num2 As DoubleDim result As Doublenum1 = CDbl(txtNum1.Text)num2 = CDbl(txtNum2.Text)If rbAdd.Checked Thenresult = num1 + num2ElseIf rbSubtract.Checked Thenresult = num1 - num2ElseIf rbMultiply.Checked Thenresult = num1 * num2ElseIf rbDivide.Checked ThenIf num2 <> 0 Thenresult = num1 / num2ElseMsgBox("Error: Division by zero!")End IfEnd IftxtResult.Text = resultEnd Sub```实验二:学生成绩管理系统要求:编写一个学生成绩管理系统,能够实现学生信息的录入、查询和统计功能。

参考答案:```vbPrivate Sub btnAdd_Click()Dim name As StringDim score As Integername = txtName.Textscore = CInt(txtScore.Text)lstStudents.Items.Add(name & " - " & score)End SubPrivate Sub btnSearch_Click()Dim searchName As StringDim index As IntegersearchName = txtSearch.Textindex = lstStudents.FindString(searchName)If index <> -1 ThenlstStudents.SelectedIndex = indexElseMsgBox("Student not found!")End IfEnd SubPrivate Sub btnStatistics_Click()Dim totalScore As IntegerDim averageScore As DoubleDim count As IntegerFor Each item As String In lstStudents.ItemsDim score As Integer = CInt(item.Split("-")(1).Trim()) totalScore += scorecount += 1NextaverageScore = totalScore / counttxtTotalScore.Text = totalScoretxtAverageScore.Text = averageScore```实验三:简单的图书管理系统要求:编写一个简单的图书管理系统,能够实现图书信息的录入、查询和删除功能。

《Visual_Basic程序设计》试题及其答案

《Visual_Basic程序设计》试题及其答案

《Visual_Basic程序设计》试题及其答案Visual_Basic程序设计试题及其答案Visual_Basic程序设计是一门与Windows操作系统密切相关的编程语言,广泛应用于图形用户界面(GUI)的开发。

下面是一套Visual_Basic程序设计的试题,以及详细的答案解析。

一、概念题(共10题,每题2分,共20分)1. 什么是Visual_Basic程序设计?答案:Visual_Basic程序设计是一种基于BASIC语言的集成开发环境(IDE),用于Windows平台的程序开发和编程。

2. Visual_Basic程序设计的特点是什么?答案:Visual_Basic具有简单易学、图形化编程界面、可视化设计、事件驱动等特点。

3. 什么是控件?答案:控件是Visual_Basic程序设计中用于构建用户界面的基本元素,如按钮、文本框、标签等。

4. Visual_Basic程序中的数据类型有哪些?答案:Visual_Basic支持多种数据类型,包括整数、浮点数、字符串、布尔值等。

5. 什么是条件结构?答案:条件结构是一种根据不同条件执行不同操作的程序结构,如If语句和Select Case语句。

6. 什么是循环结构?答案:循环结构是一种重复执行特定操作的程序结构,如For循环和While循环。

7. 什么是函数?答案:函数是一段可重复调用的代码,通常用于实现特定功能,并可以返回结果。

8. 如何定义和调用函数?答案:在Visual_Basic中,可以使用Function关键字定义函数,并使用函数名调用函数。

9. 什么是异常处理?答案:异常处理是一种处理程序运行过程中可能出现的错误或异常情况的机制,以保证程序的稳定性。

10. Visual_Basic程序如何进行调试?答案:Visual_Basic提供了丰富的调试工具,包括断点调试、单步调试等,以帮助程序员发现和解决问题。

二、编程题(共2题,每题40分,共80分)题目一:设计一个Visual_Basic程序,实现计算器的基本功能。

《Visual Basic程序设计教程(第2版)》习题参考答案

《Visual Basic程序设计教程(第2版)》习题参考答案

《Visual Basic程序设计教程》(第2版)林卓然编著电子工业出版社2007年7月出版习题1一、单选题1.D 2.D 3.B 4.B 5.C 6.A7.A 8.A 9.B 10.B 11.B 12.B二、多选题1.ADE 2.AB 3.BCDE 4.CD 5.CE三、填空题1.属性,方法,事件 2.解释,编译 3.设计,运行,中断 4.Command2_Click 5.中央,代码 6.MyForm.frm 7.(1)Cmd1_Click(),(2)Txt1.Text="VB语言程序设计"习题2一、单选题1.(1)A,(2)C 2.A 3.B 4.B 5.B 6.D 7.B 8.A 9.A 10.B 11.B 12.A 13.B二、多选题1.BD 2.CD 3. AD三、填空题1.(1) (2+x*y)/(2–y*y) (2) a^2–3*a*b/(3+a)(3) x^(3/8)+Sqr(y^2+4*a^2a/(x+y^3))2.Int(50+6*Rnd)3.(1)138, (2)3, (3)214, (4) 70, (5) "45", (6)04. "系统管理数据库"习题3一、单选题1.C 2.B 3.B 4.D 5.B 6.C 7.B 8.D 9.C 10.(1)A, (2)C 11.A 12.B 13.D 14.B二、多选题1.AC 2.ABF 3.BE三、填空题1.$000,124 2.Label1.Caption="a*b=" 3.Height,Width4.2 5.Text1.SetFocus6.Multiline, ScrollBars, 2 7.24,2423习题4一、单选题1.C 2.B 3.C 4.C 5.D 6.B 7.(1)D,(2)A,(3)B 二、多选题1.ABCFGHJ 2.BE 3.CDE 4.AE三、填空题1.60000 2.O&pen 3.(1) "0" To "9";(2) "a" To "z", "A" To "Z";(3) Else习题5一、单选题1.B 2.(1)D,(2)C 3.A 4.(1)B,(2)C,(3)B 5.B 6.B 二、填空题1.(1) 4次,n=13;(2) 3次,n=8;(3) 3次,n=27;(4) 1次,n=12 2.227 3.0 4.Style 5.下拉列表框6.AddItem,RemoveItem或Clear 7.(1)ItemA,(2) ItemD,(3) ItemD,(4) ItemA习题6一、单选题1.D 2.A 3.B 4.C 5.C 6.A 7.(1)D (2)A (3)B 二、多选题1.AD 2.CD三、填空题1.二, 12; 1, 3; -1, 22. 0 1 2 31 0 1 22 1 0 13 2 1 03. Name, Index 4.(1) 0 To Index, (2)Val(Text1(k).Text)习题7一、单选题1.B 2.C 3.B 4.B 5.C 6.D 7.A 8.C 9.D 10.C 二、填空题1.EF 2.(1)14,(2) 2,(3)10 3.(1)10,(2)28,(3)6,(4) 64.(1)Power(x,n-1)*x,(2)Power = x习题8一、单选题1.B 2.D 3.D 4.A 5.B 6.D 7.A8.(1)D,(2)D 9.B 10.A 11.D二、填空题1. Get, Put2.(1) Open "Myfile3.txt" For Output(2) Write #1, StNo, StMb (3) Close #13. (1) Open " Myfile3.txt" For Input As #1 (2) EOF(1)(3) Input #1, StNo, StMb习题9单选题1.B 2.D 3.D 4.B 5.A 6.A习题10一、单选题1.C 2.(1)A,(2)C 3.C 4.A 5.(1)A,(2)D 6.A 7.D 8.B 9.D二、填空题1.(1)Change,(2)Value,(3)Scroll,(4)Value2.Circle(Scale.Width/2,Scale.Height/2),10003.(1) P1.Picture ,(2) P2.Picture,(3) P2.Picture = P3.Picture4.KeyDown,KeyPress,KeyUp 5.MouseDown,MouseUP6.菜单编辑器,顶;PopUpMenu7.(1) Button.Index (2) BackColor = RGB(255, 0, 0)(3) BackColor = RGB(0, 255, 0) (4) BackColor = RGB(0, 0, 255)8.(1)DragMode, (2)1,(3)0 9.(1)Action, (2)4, (3)ShowFont10.(1)KeyPress, (2)Cls, (3)CurrentY = Y, (4) Button=1习题11一、单选题1.C 2.C 3.A 4.D 5.A 6.D 7.D 8.C9.D 10.D 11.C 12.A 13.B二、填空题1.Select 职工号,基本工资 From 工资表 Where 基本工资>5002.Update 职工表 Set 姓名="伍小明" Where 职工号="00018"3.Select 学籍表.班号,Avg(成绩表.英语) From 成绩表,学籍表 Where 学籍表.学号=成绩表.学号 Group By 学籍表.班号4.Update 工资表 Set 基本工资=基本工资+1005.Delete From 工资表 Where 基本工资<2006.Insert Into 学籍表(学号,姓名,性别,年龄,班号) Values("951009","林东生","男",20,"31")(完)。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实验一VERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3195ClientLeft = 60ClientTop = 345ClientWidth = 4680LinkTopic = "Form1"ScaleHeight = 3195ScaleWidth = 4680StartUpPosition = 3 '窗口缺省 Begin mandButton Command1 Caption = "Command1" Height = 375Left = 2640TabIndex = 0Top = 2400Width = 1575EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = FalsePrivate Sub Command1_Click()Print Sqr(8), 8 ^ (1 / 3)End SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3195ClientLeft = 60ClientTop = 345ClientWidth = 4680LinkTopic = "Form1"ScaleHeight = 3195ScaleWidth = 4680StartUpPosition = 3 '窗口缺省 Begin mandButton Command1 Caption = "Command1" Height = 495Left = 3720TabIndex = 0Top = 2640Width = 855EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = True Attribute VB_Exposed = FalsePrivate Sub Command1_Click()Dim i%For i = 100 To 110Print i, i ^ (1 / 2)NextEnd SubVERSION 5.00Begin VB.Form Form1AutoRedraw = -1 'TrueCaption = "Form1"ClientHeight = 3195ClientLeft = 60ClientTop = 345ClientWidth = 4680BeginProperty FontName = "楷体_GB2312" Size = 21.75Charset = 134Weight = 400Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyForeColor = &H000000FF&LinkTopic = "Form1"ScaleHeight = 3195ScaleWidth = 4680StartUpPosition = 3 '窗口缺省EndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = True Attribute VB_Exposed = FalsePrivate Sub Form_Load()Print: PrintPrint " 郑州大学在前进!"End SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3780ClientLeft = 60ClientTop = 345ClientWidth = 6285LinkTopic = "Form1"ScaleHeight = 3780ScaleWidth = 6285StartUpPosition = 3 '窗口缺省Begin bel Label1Caption = "蓝天、白云、绿水、青山" BeginProperty FontName = "宋体"Size = 21.75Charset = 134Weight = 400Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyForeColor = &H00FF0000&Height = 975Left = 600TabIndex = 0Top = 1080Width = 4935EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = False实验2VERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3090ClientLeft = 60ClientTop = 450ClientWidth = 3615BeginProperty FontName = "宋体"Size = 12Charset = 134Weight = 700Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndPropertyLinkTopic = "Form1"ScaleHeight = 3090ScaleWidth = 3615StartUpPosition = 3 '窗口缺省 Begin mandButton Command2 Caption = "商"Height = 375Left = 1920TabIndex = 4Top = 1680Width = 975EndBegin mandButton Command1 Caption = "乘积"Height = 375Left = 600TabIndex = 3Top = 1680Width = 975EndBegin VB.TextBox Text2Height = 375Left = 1920TabIndex = 2Top = 840Width = 1095EndBegin VB.TextBox Text1Height = 375Left = 480TabIndex = 1Top = 840Width = 1095EndBegin bel Label3BorderStyle = 1 'Fixed Single Caption = "Label3"Height = 375Left = 2040TabIndex = 6Top = 2400Width = 975EndBegin bel Label2Caption = "计算结果为:" Height = 375Left = 480TabIndex = 5Top = 2400Width = 1575EndBegin bel Label1AutoSize = -1 'TrueCaption = "请输入两个数:" Height = 240Left = 960TabIndex = 0Top = 360Width = 1785EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()Label3 = Val(Text1) * Val(Text2)End SubPrivate Sub Command2_Click()Label3 = Val(Text1) / Val(Text2)End SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3090ClientLeft = 60ClientTop = 450ClientWidth = 5490BeginProperty FontName = "宋体"Size = 12Charset = 134Weight = 700Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndPropertyLinkTopic = "Form1"ScaleHeight = 3090ScaleWidth = 5490StartUpPosition = 3 '窗口缺省 Begin mandButton Command3 Caption = "隐藏"Height = 375Left = 4080TabIndex = 3Top = 2040Width = 975EndBegin mandButton Command2 Caption = "图片2"Height = 375Left = 4080TabIndex = 2Top = 1320Width = 975EndBegin mandButton Command1 Caption = "图片1"Height = 375Left = 4080TabIndex = 1Top = 600Width = 975EndBegin VB.PictureBox Picture1AutoSize = -1 'True BeginProperty FontName = "宋体"Size = 9Charset = 134Weight = 400Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyHeight = 1935Left = 600ScaleHeight = 1875ScaleWidth = 2715TabIndex = 0Top = 480Width = 2775EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()Picture1.Picture = LoadPicture("d:\tu1.jpg") End SubPrivate Sub Command2_Click()Picture1.Picture = LoadPicture("d:\tu2.jpg") End SubPrivate Sub Command3_Click()Picture1.Visible = FalseEnd SubVERSION 5.00Begin VB.Form Form1Caption = "收款机"ClientHeight = 2730ClientLeft = 60ClientTop = 450ClientWidth = 4680BeginProperty FontName = "宋体"Size = 12Weight = 700Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyLinkTopic = "Form1"ScaleHeight = 2730ScaleWidth = 4680StartUpPosition = 3 '窗口缺省Begin mandButton Command1Caption = "总价为"Height = 375Left = 600TabIndex = 4Top = 1920Width = 1695EndBegin VB.TextBox Text2Height = 495Left = 3000TabIndex = 3Top = 960Width = 1335EndBegin VB.TextBox Text1Height = 495Left = 3000TabIndex = 2Top = 240Width = 1335EndBegin bel Label3Alignment = 2 'CenterBorderStyle = 1 'Fixed SingleHeight = 495Left = 2760TabIndex = 5Top = 1920Width = 1455EndBegin bel Label2Alignment = 2 'CenterCaption = "货物的单价(元):"Left = 360TabIndex = 1Top = 1080Width = 2295EndBegin bel Label1Alignment = 2 'CenterCaption = "货物的数量(个):" Height = 375Left = 360TabIndex = 0Top = 360Width = 2295EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()Label3 = Text1 * Text2End SubBegin VB.Form Form1Caption = "Form1"ClientHeight = 1890ClientLeft = 60ClientTop = 450ClientWidth = 4365LinkTopic = "Form1"ScaleHeight = 1890ScaleWidth = 4365StartUpPosition = 3 '窗口缺省Begin mandButton Command2Caption = "清除"BeginProperty FontName = "宋体"Size = 12Charset = 134Weight = 700Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyHeight = 375Left = 2400TabIndex = 3Top = 1200Width = 975EndBegin mandButton Command1Caption = "复制"BeginProperty FontName = "宋体"Size = 12Charset = 134Weight = 700Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndPropertyHeight = 375Left = 720TabIndex = 2Top = 1200Width = 975EndBegin VB.TextBox Text2Height = 495Left = 2160TabIndex = 1Top = 360Width = 1695EndBegin VB.TextBox Text1Height = 495Left = 480TabIndex = 0Top = 360Width = 1455EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = True Attribute VB_Exposed = FalsePrivate Sub Command1_Click()Text2 = Text1End SubPrivate Sub Command2_Click()Text1 = ""Text2 = ""End SubPrivate Sub Form_Load()Command1.Visible = FalseCommand2.Visible = FalseEnd SubPrivate Sub Text1_Change() Command1.Visible = TrueCommand2.Visible = TrueEnd SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3300ClientLeft = 60ClientTop = 450ClientWidth = 4695BeginProperty FontName = "宋体"Size = 12Charset = 134Weight = 700Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndPropertyLinkTopic = "Form1"ScaleHeight = 3300ScaleWidth = 4695StartUpPosition = 3 '窗口缺省 Begin VB.Timer Timer1Enabled = 0 'False Interval = 500Left = 3120Top = 1320EndBegin mandButton Command2Caption = "停止"Height = 495Left = 2640TabIndex = 1Top = 2400Width = 975EndBegin mandButton Command1Caption = "移动"Height = 495Left = 840TabIndex = 0Top = 2400Width = 1095EndBegin VB.Image Image1Height = 1800Left = 840Top = 360Width = 1500EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Form_Load()Image1.Picture = LoadPicture("d:\tu3.jpg")End SubPrivate Sub Command1_Click()Timer1.Enabled = TrueEnd SubPrivate Sub Command2_Click()Timer1.Enabled = FalseEnd SubPrivate Sub Timer1_Timer()Image1.Left = Int(Rnd * (Form1.ScaleWidth - Image1.Width)) Image1.Top = Int(Rnd * (Form1.ScaleHeight - Image1.Height))End Sub实验3VERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3195ClientLeft = 60ClientTop = 345ClientWidth = 4680LinkTopic = "Form1"ScaleHeight = 3195ScaleWidth = 4680StartUpPosition = 3 '窗口缺省 Begin mandButton Command1 Caption = "Command1" Height = 495Left = 3720TabIndex = 0Top = 2640Width = 855EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = FalsePrivate Sub Command1_Click()Print 2 * 3 ^ 2 * 8 / 4 + 3 ^ 2Print Sqr(Sqr(64))Print #2/27/2004# - 10Print Int(-3.1415926)Print Int(Abs(99 - 100) / 2)Print Fix(-3.1415926)Print Int(-3.5), Int(3.5)Print Fix(3.5), Fix(3.5)Print Sgn(7 * 3 + 2)Print LCase("Hello")Print Val("16Year")Print Str(-459.65)Print Len("Hello 程序设计 ok")Print "MNT" & 123 & "ABC"Print 123 + Mid("123456", 3, 2)Print 123 & Mid("123456", 3, 2)Print DateAdd("m", 1, #2/27/2004#)End SubCaption = "Form1"ClientHeight = 3195ClientLeft = 60ClientTop = 345ClientWidth = 6825BeginProperty FontName = "宋体"Size = 15Charset = 134Weight = 700Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyLinkTopic = "Form1"ScaleHeight = 3195ScaleWidth = 6825StartUpPosition = 3 '窗口缺省Begin VB.TextBox Text1Height = 495Left = 3120TabIndex = 2Text = "Text1"Top = 240Width = 1695EndBegin mandButton Command1Caption = "计算平方立方(根)" BeginProperty FontName = "宋体"Size = 14.25Charset = 134Weight = 700Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyHeight = 495Left = 1680TabIndex = 0Top = 960EndBegin bel Label2Caption = "Label2"Height = 735Left = 480TabIndex = 3Top = 1920Width = 5895EndBegin bel Label1Caption = "输入一个数"Height = 495Left = 1320TabIndex = 1Top = 240Width = 1935EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()Dim n%n = Abs(Val(Text1))Label2 = Format(n ^ 2, "#.000") & Space(2) & Format(Sqr(n), "#.000") & Space(2) & Format(n ^ 3, "#.000") & Space(2) & Format(n ^ (1 / 3), "#.000")End SubBegin VB.Form Form1Caption = "Form1"ClientHeight = 3330ClientLeft = 60ClientTop = 345ClientWidth = 5985LinkTopic = "Form1"ScaleHeight = 3330ScaleWidth = 5985StartUpPosition = 3 '窗口缺省Begin mandButton Command2Caption = "方法二"Left = 3840TabIndex = 1Top = 1800Width = 1215EndBegin mandButton Command1Caption = "方法一"Height = 495Left = 3840TabIndex = 0Top = 600Width = 1215EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()Dim x%, y%x = Int(Rnd * 900 + 100)Print "产生的随机数:"; xy = (x Mod 10) * 100 + (x \ 10 Mod 10) * 10 + x \ 100Print "反序数:"; Format(y, "000")End SubPrivate Sub Command2_Click()Dim x%, y As Stringx = Int(Rnd * 900 + 100)Print "产生的随机数:"; xy = Trim(Str(x))Print "反序数:" & Right(y, 1) & Mid(y, 2, 1) & Left(y, 1) End SubBegin VB.Form Form1Caption = "Form1"ClientHeight = 4275ClientLeft = 60ClientTop = 345ClientWidth = 6975LinkTopic = "Form1"ScaleHeight = 4275StartUpPosition = 3 '窗口缺省Begin VB.TextBox Text2Height = 615Left = 4080TabIndex = 5Top = 960Width = 1215EndBegin mandButton Command1Caption = "开始产生"Height = 495Left = 2640TabIndex = 3Top = 1920Width = 1215EndBegin VB.TextBox Text1Height = 615Left = 1200TabIndex = 0Top = 960Width = 1215EndBegin bel Label3Caption = "Label3"Height = 375Left = 840TabIndex = 4Top = 2880Width = 4695EndBegin bel Label2Alignment = 2 'CenterCaption = "到"BeginProperty FontName = "隶书"Size = 15Charset = 134Weight = 700Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndPropertyLeft = 2760TabIndex = 2Top = 1080Width = 975EndBegin bel Label1Caption = "输入随机数范围:"BeginProperty FontName = "隶书"Size = 14.25Charset = 134Weight = 700Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyHeight = 495Left = 480TabIndex = 1Top = 360Width = 2655EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()Dim m%, n%Randomizem = Val(Text1): n = Val(Text2)x = Int(Rnd * (n - m) + m)y = Int(Rnd * (n - m) + m)z = Int(Rnd * (n - m) + m)Label3 = m & "到" & n & "之间的3个随机数为: " & x & Space(3) & y & Space(3) & zEnd SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3270ClientLeft = 60ClientTop = 450ClientWidth = 6000LinkTopic = "Form1"ScaleHeight = 3270ScaleWidth = 6000StartUpPosition = 3 '窗口缺省Begin mandButton Command3Caption = "星期几"Height = 495Left = 360TabIndex = 2Top = 2280Width = 1455EndBegin mandButton Command2Caption = "时间"Height = 495Left = 360TabIndex = 1Top = 1440Width = 1455EndBegin mandButton Command1Caption = "日期"Height = 495Left = 360TabIndex = 0Top = 600Width = 1455EndBegin bel Label3BorderStyle = 1 'Fixed Single Caption = "Label3"Height = 495Left = 2520TabIndex = 5Top = 2280Width = 2535EndBegin bel Label2BorderStyle = 1 'Fixed Single Caption = "Label2"Height = 495Left = 2520TabIndex = 4Top = 1440Width = 2535EndBegin bel Label1BorderStyle = 1 'Fixed Single Caption = "Label1"Height = 495Left = 2520TabIndex = 3Top = 600Width = 2535EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()Label1.Caption = DateEnd SubPrivate Sub Command2_Click()Label2.Caption = TimeEnd SubPrivate Sub Command3_Click()Label3.Caption = WeekdayName(Weekday(Date)) End Sub实验4VERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 4305ClientLeft = 60ClientTop = 450ClientWidth = 6345BeginProperty FontName = "宋体"Size = 14.25Charset = 134Weight = 700Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyLinkTopic = "Form1"ScaleHeight = 4305ScaleWidth = 6345StartUpPosition = 3 '窗口缺省Begin mandButton Command1Caption = "转换"Height = 495Left = 2160TabIndex = 2Top = 1800Width = 1455EndBegin VB.TextBox Text1Height = 495Left = 3480TabIndex = 1Top = 720Width = 1455EndBegin bel Label2Height = 975Left = 360TabIndex = 3Top = 2760Width = 5775EndBegin bel Label1Caption = "请输入弧度数值:" Height = 495Left = 600TabIndex = 0Top = 720Width = 2415EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalseOption ExplicitPrivate Sub Command1_Click()Dim x!, a!, aa%, b!, bb%, c!, cc$x = Val(Text1)a = x * 180 / 3.14aa = Int(a)b = (a - aa) * 60bb = Int(b)c = (b - bb) * 60cc = Format(c, "#.000")Label2 = "弧度" & Text1 & "转换为" & aa & "度" & bb & "分" & cc & "秒"End SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3255ClientLeft = 60ClientTop = 450ClientWidth = 4980LinkTopic = "Form1"ScaleHeight = 3255ScaleWidth = 4980StartUpPosition = 3 '窗口缺省Begin mandButton Command1Caption = "判断"Height = 495Left = 1560TabIndex = 2Top = 1440Width = 1335EndBegin VB.TextBox Text1Height = 615Left = 960TabIndex = 0Top = 600Width = 2655EndBegin bel Label2Height = 735Left = 960TabIndex = 3Top = 2160Width = 2775EndBegin bel Label1Caption = "输入一个年份:"Height = 375Left = 1320TabIndex = 1Top = 240Width = 1935EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()Dim x%x = Val(Text1)If x / 400 = x \ 400 Or x Mod 4 = 0 And x Mod 100 <> 0 Then Label2 = Text1 & "年是闰年"ElseLabel2 = Text1 & "年不是闰年"End IfEnd SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3090ClientLeft = 60ClientTop = 450ClientWidth = 4680LinkTopic = "Form1"ScaleHeight = 3090ScaleWidth = 4680StartUpPosition = 3 '窗口缺省Begin mandButton Command1Caption = "3个数排序"Height = 495Left = 1800TabIndex = 0Top = 1320Width = 1215EndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = FalsePrivate Sub Command1_Click()Dim x%, y%, z%x = InputBox("输入第一个数")y = InputBox("输入第二个数")z = InputBox("输入第三个数")If x > y Then t = x: x = y: y = t If y > z Then t = y: y = z: z = t If x > y Then t = x: x = y: y = t Print x, y, zEnd SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 5430ClientLeft = 60ClientTop = 450ClientWidth = 6975LinkTopic = "Form1"ScaleHeight = 5430ScaleWidth = 6975StartUpPosition = 3 '窗口缺省 Begin mandButton Command2 Caption = "结束"Height = 495Left = 3840TabIndex = 1Top = 2040Width = 1215EndBegin mandButton Command1 Caption = "计费"Height = 495Left = 1080TabIndex = 0Top = 2040Width = 1215EndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()x = Val(InputBox("请输入上网时间:"))If x <> -1 ThenSelect Case xCase Is < 10fei = 25Case 10 To 50fei = x * 2Case 50 To 100fei = x * 1.5Case Is >= 100fei = x * 1End SelectMsgBox "上网费用为:" & fei & "元"End IfEnd SubPrivate Sub Command2_Click()EndEnd SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 4050ClientLeft = 60ClientTop = 450ClientWidth = 6285LinkTopic = "Form1"ScaleHeight = 4050ScaleWidth = 6285StartUpPosition = 3 '窗口缺省Begin mandButton Command1Caption = "弧度转换为度分秒" Height = 615Left = 2160TabIndex = 0Top = 1560EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()x = InputBox("请输入弧度数值", "弧度转换", 0)xx = Val(x)a = x * 180 / 3.14aa = Int(a)b = (a - aa) * 60bb = Int(b)c = (b - bb) * 60cc = Format(c, "#.000")MsgBox "弧度" & x & "转换为" & aa & "度" & bb & "分" & cc & "秒" End SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 5430ClientLeft = 60ClientTop = 450ClientWidth = 6975LinkTopic = "Form1"ScaleHeight = 5430ScaleWidth = 6975StartUpPosition = 3 '窗口缺省Begin mandButton Command2Caption = "结束"Height = 495Left = 3840TabIndex = 1Top = 2040Width = 1215EndBegin mandButton Command1Caption = "计费"Height = 495Left = 1080TabIndex = 0Top = 2040EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()Dox = Val(InputBox("请输入上网时间:", , -1)) If x <> -1 ThenSelect Case xCase Is < 10fei = 25Case 10 To 50fei = x * 2Case 50 To 100fei = x * 1.5Case Is >= 100fei = x * 1End Selectzongfei = zongfei & Space(3) & feiMsgBox zongfei, , "上网费用为"ElseExit DoEnd IfLoopEnd SubPrivate Sub Command2_Click()EndEnd Sub实验5VERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3090ClientLeft = 60ClientTop = 450ClientWidth = 4680LinkTopic = "Form1"ScaleHeight = 3090ScaleWidth = 4680StartUpPosition = 3 '窗口缺省 Begin mandButton Command1 Caption = "Command1" Height = 495Left = 1800TabIndex = 0Top = 1320Width = 1215EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = FalsePrivate Sub Command1_Click()For n = 1 To 100s = s + nNext nPrint sEnd SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3090ClientLeft = 60ClientTop = 450ClientWidth = 4680LinkTopic = "Form1"ScaleHeight = 3090ScaleWidth = 4680StartUpPosition = 3 '窗口缺省 Begin mandButton Command1 Caption = "Command1" Height = 495Left = 1920TabIndex = 0Top = 1680Width = 1215EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()For i = 0 To 20For j = 0 To 33If i * 5 + j * 3 + 1 / 3 * (100 - i - j) = 100 Then Print i, j, 100 - i - jNextNextEnd SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3090ClientLeft = 60ClientTop = 450ClientWidth = 4680LinkTopic = "Form1"ScaleHeight = 3090ScaleWidth = 4680StartUpPosition = 3 '窗口缺省Begin mandButton Command1Caption = "Command1"Height = 495Left = 1800TabIndex = 0Top = 1320Width = 1215EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()n = 0DoIf n Mod 2 = 1 And n Mod 3 = 2 And n Mod 5 = 4 And n Mod 6 = 5 And n Mod 7 = 0 Then Exit Don = n + 1LoopPrint nEnd SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3090ClientLeft = 60ClientTop = 450ClientWidth = 4680LinkTopic = "Form1"ScaleHeight = 3090ScaleWidth = 4680StartUpPosition = 3 '窗口缺省 Begin mandButton Command2 Caption = "方法2"Height = 495Left = 2880TabIndex = 1Top = 1320Width = 1215EndBegin mandButton Command1 Caption = "方法1"Height = 495Left = 2880TabIndex = 0Top = 480Width = 1215EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = FalsePrivate Sub Command1_Click()Dim x%, y%, z%, i%, j%For x = 0 To 9For y = 0 To 9For z = 0 To 9i = x * 100 + x * 10 + zj = y * 100 + z * 10 + zIf i + j = 532 Then Print x; y; z。

相关文档
最新文档