郑州大学VB实验报告书 参考 答案
【参考文档】vb实验指导书答案-范文word版 (10页)

第6章 过程
一、单选题
二、填空题 2.5 5. 工具 7. &,Click 8. Enabled 9. 窗体
10. 模式,无模式
11. Action
12. CommonDialog1.FileName 13. cdlCCRGBInit 14. Unload,Show 15. 所在窗体的名称 16. 打开 17. Visible 18. 当前 19. 255 20. Show
(6)强制显式声明变量 (7)类 P35 第三章
1. CBAAABCDAD ABBBC ADDBD 2.(1)integer (2)???? (3)text (4)a=0 or b=0 (5)(x+y)*sin(30*3.14/180) (6)int(rnd*100+1)(7)# (8)0
1
C
(9)int(rnd*30+70)(10) CDEF P53 第四章
本文部分内容来自网络整理,本司不为其真实性负责,如有异议或侵权请及时联系,本司将立即删除!
== 本文为word格式,下载后可方便编辑和修改! ==
vb实验指导书答案
篇一:VB程序设计学习与实验指导书答案(包含实验答案)
VB学习与实验指导测试题
参考答案
第一章
第二章
第三章
第四章
第五章
第六章
第七章
第八章
篇二:VB实验指导书答案
vb实验报告(答案)

Print "数理化"
End Sub
Private Sub Cmd2_Click()
Print "政史地"
End Sub
心得体会:(可以从以下几个方面来总结:你在上机过程中遇到了哪些难题?你是怎么克服的?你对你的程序的评价?你的收获有哪些?你有什么没有解决的问题?等)
A. Text1.MaxLength = 0 B. Text1.Enabled = False
C. Text1.Visible = FalseD. Text1.Width = 0
5、设置命令按钮的属性时,只有将(A)属性设置为1,Picture属性才有效,否则无效。
A、StyleB、CaptionC、EnabledD、Default
试验报告(1)
院(系):课程名称:日期:
班级
学号
实验室
专业
姓名
计算机号
实验
名称
VB环境的熟悉与应用
成绩评定
所用
软件
Visual Basic 6.0
教师签名
实
验
目
的
或
要
求
1.熟悉VB的系统环境,了解VB程序的编写、保存和编译的方法过程。
2.初步了解几个常用控件的使用方法。
实
验
步
骤
、
心
得
体
会
1、在vb中____C_____被称为对象。
10、确定一个控件在窗体上位置的属性是__Left_______和___Top______。
11、窗体边框类型的默认值是___2___。
9、Visual Basic集成开发环境主要窗口包括__窗体设计窗口;代码设计窗口;_属性窗口;_工程资源管理器窗口_;_工具箱窗口。
VisualBasic程序设计—试验报告册-参考答案

实验一VERSION 5.00Begin VB.Form Form1Caption = "Form1" ClientHeight = 3195ClientLeft = 60ClientTop = 345ClientWidth = 4680LinkTopic = "Form1"ScaleHeight = 3195ScaleWidth = 4680 StartUpPosition = 3 ' 窗口缺省Begin mandButton Command1Caption = "Command1"Height = 375Left = 2640TabIndex = 0Top = 2400Width = 1575EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = True Attribute VB_Exposed = FalsePrivate Sub Command1_Click()Print Sqr(8), 8 A (1 / 3)End SubVERSION 5.00Begin VB.Form Form1Caption = "Form1" ClientHeight = 3195ClientLeft = 60ClientTop = 345ClientWidth = 4680LinkTopic = "Form1"ScaleHeight = 3195ScaleWidth = 4680 StartUpPosition = 3 ' 窗口缺省Begin mandButton Command1Caption = "Command1"Height = 495Left = 3720TabIndex = 0Top = 2640Width = 855EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()Dim i%For i = 100 To 110Print i, i A (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 = 4680 StartUpPosition = 3 ' 窗口缺省EndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = True Attribute VB_Exposed = False窗口缺省蓝天、白云、绿水、青山宋体"Private Sub Form_Load()Print: PrintPrint " 郑州大学在前进! "End SubVERSION 5.00Begin VB.Form Form1Caption = "Form1" ClientHeight = 3780ClientLeft = 60ClientTop = 345 ClientWidth = 6285LinkTopic = "Form1"ScaleHeight = 3780ScaleWidth = 6285 StartUpPosition = 3 ' Beginbel Label1Caption = " BeginProperty FontName = " Size = 21.75 Charset = 134Weight = 400Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'False EndPropertyForeColor = &H00FF0000&TabIndex = 0 Top = 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 = 3090 Height Left = 975= 600ClientLeft = ClientTop ClientWidth60 = 450 = 3615BeginProperty FontName Size Charset Weight Underline Italic = = " 宋体"12= 134= 700= 0 'FalseStrikethrough = 0 'FalseEndProperty LinkTopic ScaleHeight ScaleWidth = "Form1" = 3090= 3615StartUpPosition = 3 ' 窗口缺省Begin mandButton Command2Caption Height Left = TabIndex Top Width End = " 商" = 3751920= 4= 1680= 975Begin mandButton Command1Caption Height Left = TabIndex Top Width End = " 乘积" = 375 600= 3= 1680 = 975Begin VB.TextBox Text2Height Left = TabIndex Top Width End = 375 1920 = 2 = 840= 1095Begin VB.TextBox Text1Height Left = TabIndex Top = 375480= 1 = 840Width = 1095EndBegin bel Label3BorderStyle = 1 'Fixed SingleCaption = "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 'FalseItalic = 0 'FalseStrikethrough = 0 'False EndPropertyLinkTopic = "Form1"ScaleHeight = 3090ScaleWidth = 5490 StartUpPosition = 3 ' 窗口缺省Begin mandButton Command3Caption = " 隐藏"Height = 375Left = 4080TabIndex = 3Top = 2040Width = 975EndBegin mandButton Command2Caption = " 图片2"Height = 375Left = 4080TabIndex = 2Top = 1320Width = 975EndBegin mandButton Command1Caption = " 图片1"Height = 375宋体" Left = 4080TabIndex = 1Top= 600 Width= 975 EndBegin VB.PictureBox Picture1AutoSize = -1 'TrueBeginProperty FontName= " Size = 9Charset= 134 Weight= 400 Underline =0 'False Italic = 0'False Strikethrough = 0 'FalseEndPropertyHeight = 1935Left = 600ScaleHeight = 1875ScaleWidth = 2715TabIndex = 0Top= 480 Width= 2775 EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = True Attribute 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 = False End SubVERSION 5.00Begin VB.Form Form1Caption = " 收款机 " ClientHeight = 2730ClientLeft = 60ClientTop = 450ClientWidth = 4680BeginProperty FontName = " 宋体"Size = 12Charset = 134Weight = 700Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyLinkTopic = "Form1" ScaleHeight = 2730 ScaleWidth = 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 Single Height = 495Left = 2760TabIndex = 5Top = 1920Width = 1455EndBegin bel Label2Alignment = 2 'CenterCaption = " 货物的单价(元):Height = 375Left = 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 * Text2 End SubBegin VB.Form Form1Caption = "Form1"ClientHeight = 1890ClientLeft = 60ClientTop = 450 ClientWidth = 4365LinkTopic = "Form1" ScaleHeight = 1890 ScaleWidth = 4365StartUpPosition = 3 ' 窗口缺省Begin mandButton Command2 Caption = "清除"BeginProperty FontName = " 宋体"Size = 12 Charset =134Weight = 700Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyHeight = 375Left = 2400TabIndex = 3Top = 1200Width = 975EndBegin mandButton Command1 Caption = "复制"BeginProperty FontName = " 宋体"Size = 12Charset = 134Weight = 700Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyHeight = 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 = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click()Text2 = Text1End SubPrivate Sub Command2_Click()Text1 = ""Text2 = ""End SubPrivate Sub Form_Load()Command1.Visible = FalseCommand2.Visible = False End SubPrivate Sub Text1_Change()Command1.Visible = TrueCommand2.Visible = True End SubVERSION 5.00Begin VB.Form Form1Begin mandButton Command2 Caption = " 停止"Height = 495Caption = "Form1"ClientHeight = 3300ClientLeft =60 ClientTop = 450ClientWidth = 4695BeginProperty FontName= " Size =12 Charset= 134 Weight =700 Underline= 0 'False Italic =0 'False Strikethrough = 0 'False EndPropertyLinkTopic ="Form1" ScaleHeight3300 ScaleWidth = 4695StartUpPosition = 3 'Begin VB.Timer Timer1Enabled= 0 'False Interval =500 Left =3120 Top = 1320End 宋体" 窗口缺省Left = 2640TabIndex = 1Top = 2400Width = 975EndBegin mandButton Command1 Caption = " 移动"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 Command1Caption = "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()Print 2 * 3 A 2 * 8 / 4 + 3 A 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 = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 6825 BeginProperty FontName = " 宋体"Size = 15Charset = 134Weight = 700Underline = 0 'False Italic = 0 'FalseStrikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 6825StartUpPosition = 3 ' 窗口缺省Begin VB.TextBox Text1Height = 495Left = 3120 TabIndex = 2Text = "Text1"Top = 240Width = 1695EndBegin mandButton Command1Caption = " 计算平方立方(根) " BeginProperty FontName = " 宋体" Size = 14.25 Charset = 134Weight = 700Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'False EndProperty Height = 495Left = 1680TabIndex = 0 Top= 960Width = 3015EndBegin 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 A 2, "#.000") & Space(2) & Format(Sqr( n), "#.000") & Space(2) & Format(n A 3, "#.000") & Space(2) & Format(n A (1 / 3), "#.000") End SubBegin VB.Form Form1Caption = "Form1"ClientHeight = 3330ClientLeft = 60ClientTop = 345ClientWidth = 5985LinkTopic = "Form1"ScaleHeight = 3330ScaleWidth = 5985StartUpPosition = 3 ' 窗口缺省Begin mandButton Command2Caption = " 方法二"Height = 495Left = 3840 TabIndex = 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 String x = Int(Rnd * 900 + 100)Print " 产生的随机数:"; xy = Trim(Str(x))Print " 反序数:" & Right(y, 1) & Mid(y, 2, 1) & Left(y, 1) End Sub Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4275 ClientLeft = 60 ClientTop = 345 ClientWidth = 6975 LinkTopic = "Form1" ScaleHeight = 4275ScaleWidth = 6975 StartUpPosition = 3 ' 窗口缺省Begin VB.TextBox Text2Height = 615Left = 4080TabIndex = 5Top = 960Width = 1215EndBegin mandButton Command1 Caption = " 开始产生" 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 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyHeight = 375Left = 2760 TabIndex = 2Top = 1080Width = 975EndBegin bel Label1Caption = " 输入随机数范围:" BeginProperty FontName = " 隶书" Size = 14.25Charset = 134Weight = 700Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'FalseEndPropertyHeight = 495Left = 480 TabIndex = 1Top = 360Width = 2655EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = False Attribute VB_PredeclaredId = TrueAttribute VB_Exposed = False Private Sub Command1_Click()Dim m%, n%Randomize m = 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) & z End SubVERSION 5.00Begin VB.Form Form1 Caption = "Form1"ClientHeight = 3270ClientLeft = 60ClientTop = 450ClientWidth = 6000LinkTopic = "Form1"ScaleHeight = 3270ScaleWidth = 6000StartUpPosition = 3 ' 窗口缺省Begin mandButton Command3 Caption = " 星期几" Height = 495Left = 360TabIndex = 2Top = 2280Width = 1455EndBegin mandButton Command2 Caption = " 时间" Height = 495Left = 360TabIndex = 1Top = 1440Width = 1455EndBegin mandButton Command1 Caption = " 日期" Height = 495Left = 360TabIndex = 0Top = 600Width = 1455EndBegin bel Label3BorderStyle = 1 'Fixed SingleCaption = "Label3"Height = 495Left = 2520TabIndex = 5Top = 2280Width = 2535EndBegin bel Label2BorderStyle = 1 'Fixed SingleCaption = "Label2"Height = 495Left = 2520TabIndex = 4Top = 1440Width = 2535EndBegin bel Label1BorderStyle = 1 'Fixed SingleCaption = "Label1"Left = 2520TabIndex = 3Top = 600Width = 2535EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = False Private Sub Command1_Click() Label1.Caption = Date End 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"ScaleWidth = 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 = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalseOption Explicit分" & cc & " Private Sub Command1_Click()Dim x!, a!, aa%, b!, bb%, c!, cc$x = Val(Text1)a = x * 180 / 3.14 aa = Int(a)b = (a - aa) * 60bb = Int(b)c = (b - bb) * 60cc = Format(c, "#.000")Label2 = " 弧度 " & Text1 & " 转换为 " & aa & " 度 " & bb & " 秒" End SubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 3255ClientLeft = 60ClientTop = 450ClientWidth = 4980LinkTopic = "Form1"ScaleHeight = 3255ScaleWidth = 4980StartUpPosition = 3 ' 窗口缺省Begin mandButton Command1Caption = " 判断 "Height = 495Left = 1560 TabIndex = 2Top = 1440Width = 1335EndBegin VB.TextBox Text1Height = 615Left = 960TabIndex = 0Top = 600Width = 2655EndBegin bel Label2Height = 735Left = 960 TabIndex = 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 Sub VERSION 5.00Begin VB.Form Form1 Caption = "Form1"ClientHeight = 3090ClientLeft = 60ClientTop = 450ClientWidth = 4680LinkTopic = "Form1"ScaleHeight = 3090ScaleWidth = 4680StartUpPosition = 3 ' 窗口缺省Begin mandButton Command1Caption = "3 个数排序"Height = 495Left = 1800 TabIndex = 0Top = 1320Width = 1215EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False AttributeVB_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, z End Sub VERSION 5.00 Begin VB.Form Form1Caption = "Form1" ClientHeight = 5430 ClientLeft = 60 ClientTop = 450 ClientWidth = 6975 LinkTopic = "Form1" ScaleHeight = 5430 ScaleWidth = 6975 StartUpPosition = 3 '窗口缺省Begin mandButton Command2Caption = " 结束"Height = 495 Left = 3840 TabIndex = 1 Top = 2040Width = 1215EndBegin mandButton Command1 Caption = " 计费"Height = 495Left = 1080 TabIndex = 0 Top = 2040Width = 1215EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute 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 Sub VERSION 5.00Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4050 ClientLeft = 60 ClientTop = 450 ClientWidth = 6285 LinkTopic = "Form1" ScaleHeight = 4050 ScaleWidth = 6285 StartUpPosition = 3 ' 窗口缺省Begin mandButton Command1Caption = " 弧度转换为度分秒Height = 615秒"Left = 2160TabIndex = 0Top = 1560Width = 2415EndEndAttribute 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 & " EndSubVERSION 5.00Begin VB.Form Form1Caption = "Form1"ClientHeight = 5430ClientLeft = 60ClientTop = 450ClientWidth = 6975LinkTopic = "Form1"ScaleHeight = 5430ScaleWidth = 6975StartUpPosition = 3 ' 窗口缺省Begin mandButton Command2Caption = " 结束 "Height = 495Left = 3840 TabIndex = 1Top = 2040Width = 1215EndBegin mandButton Command1Caption = " 计费 "Height = 495Left = 1080TabIndex = 0Top = 2040Width = 1215End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dox = Val(InputBox(" 请输入上网时间:", , -1)) If x <> -1 ThenSelect Case x Case Is < 10fei = 25Case 10 To 50fei = x * 2Case 50 To 100fei = x * 1.5Case Is >= 100fei = x * 1End Selectzongfei = zongfei & Space(3) & fei MsgBox zongfei, , " 上网费用为" ElseExit Do End IfLoopEnd SubPrivate Sub Command2_Click()EndEnd Sub实验5VERSION 5.00Begin VB.Form Form1Caption = "Form1" ClientHeight = 3090ClientLeft = 60 ClientTop = 450ClientWidth = 4680LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 ' 窗口缺省Begin mandButton Command1 Caption = "Command1"Height = 495Left = 1800TabIndex = 0 Top = 1320Width = 1215EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click()For n = 1 To 100 s = s + n Next n Print sEnd Sub VERSION 5.00Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 ' 窗口缺省Begin mandButton Command1Caption = "Command1"Height = 495Left = 1920 TabIndex = 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 = 1215End。
实验报告簿(程序设计基础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 对象属性文件名为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)属性设置表1.1.3 对象属性Private Sub T1_Change()T2.Text=T1.Text (T2=T1)End Sub3)保存文件:存盘时必须存放在C:\VB\Sy01文件夹下,工程文件名为sjt3.vbp,窗体文件名为sjt3.frm。
郑州大学VB实验报告书 参考 答案

End Sub Private Sub Command3_Click() Picture1.Visible = False End Sub 2-3 Private Sub Command1_Click() Label3 = Text1 * Text2 End Sub 2-4 Private Sub Command1_Click() Text2 = Text1 End Sub Private Suห้องสมุดไป่ตู้ Command2_Click() Text1 = "" Text2 = "" End Sub Private Sub Text1_Change() Command1.Visible = True Command2.Visible = True End Sub 2-5 Private Sub Command1_Click() Timer1.Interval = 500 End Sub Private Sub Command2_Click()
End If Print x, y, z End Sub 4-4 Private Sub Command1_Click() Dim nettime As Integer, money As Single nettime = Val(InputBox("每月上网时数:", "上网费用")) If nettime = -1 Then money = 0 ElseIf nettime < 10 Then money = 25 ElseIf nettime < 50 Then money = nettime * 2 ElseIf nettime < 100 Then money = nettime * 1.5 ElseIf nettime < 200 Then money = nettime Else money = 200 End If If money <> 0 Then MsgBox "该月上网费用为" & money &"元" 实验五 一 BCBAC 二 (1)for x=1 to 10 s*(1-1/x)
VB实验报告材料(含问题详解)

Else
Text4.Text = a / b
End If
End Select
End Sub
2.模拟简易计算器Command2命令的单击事件的程序代码是什么?
Private Sub Command1_Click()
Dim a!, b!
Dim c As String
a = Val(Text1.Text)
List1.AddItem a(i)
Next i
End Sub
3.单击命令按钮,在文本框中显示结果信息,则程序代码是什么?
Private Sub Command1_Click()
Dim i As Integer, max%, min%, avg!
max = a(1)
min = a(1)
avg = 0
End If
End Sub
实验四循环程序设计
一.实验目的:
1.理解循环程序设计的特点。
2.掌握常用的循环语句。
3.掌握常用的循环算法。
4.掌握图片框、图像框和计时器。
二.实验内容:
1.求
2.设计一条滚动的广告字幕。
三.实验结果:对象属性设置
1.求和结果要求窗体载入时直接显示,设置窗体的某个属性。
对象
b = Val(Text3.Text)
c = Text2.Text
If c =“+”Then
Text4.Text = a + b
ElseIf c =“-”Then
Text4.Text = a - b
ElseIf c =“*”Then
Text4.Text = a * b
ElseIf c =“/”Then
VB实验报告参考答案(本部)

实验报告参考答案(本部)实验一VB集成开发环境实验内容(3):四、设计流程①界面设计:在窗体上画一个标签。
②属性设置:标签的width设为2000,height设为300。
有边框是BordStyle设为1,背景透明是BackStyle设为0。
显示“等级考试”是将caption设为“等级考试”,居中是将Alignment 设为2。
③代码设计:无五、关键代码(注意:解题方法有多种,其它方法只要能完成实验任务也是正确的)无六、调试和测试结果至少要写测试结果正确,如果写了调试中出现的典型问题及解决方法,分数给高些实验二简单的VB程序设计实验内容(3):四、设计流程①界面设计:在窗体上画一个标签、一个命令按钮。
②属性设置:固定边框是BordStyle设为1,背景透明是BackStyle设为0。
③代码设计:分别在3个事件过程form_load(),form_click(),Cmd1_click()中编程。
其中图片从网上下载,与工程文件、窗体文件保存在同一目录,代码中使用相对路径app.path。
五、关键代码(注意:解题方法有多种,其它方法只要能完成实验任务也是正确的)Private Sub Form_Load()Form1.Picture = LoadPicture(App.Path + "\tu.jpg")Form1.Caption = "我的变化"End SubPrivate Sub Form_Click()LBL1.Top = 0LBL1.Left = 0End SubPrivate Sub Cmd1_Click()Cmd1.Height = 1500Cmd1.Width = 2000End Sub六、调试和测试结果至少要写测试结果正确,如果写了调试中出现的典型问题及解决方法,分数给高些实验三数据类型及其运算四、设计流程①界面设计:在窗体上画1个文本框、1个标签、6个命令按钮。
郑州大学VB实验报告简答

过程——指附在该对象上的程序代码,是事件的处理程序。
6、答:
参考课本12页到17页。
实验二问答题:
1、答
通用属性有:Caption标题、Enabled可用性、Visible可见性、ForeColor前景颜色、BackColor背景颜色等。
2、答
标签label是用来显示信息的,不具有输入功能。 属性有Caption、BackStyle、Alignment、BorderStyle、AutoSize。
文本框用来输入、输出数据,编辑文本。 属性有Text、 Maxlength、 MultiLine、 ScrollBars、 Locked 、 PassWord 。
实验一问答题:
1、答:
常见的有visual Basic、C++、Java、SQL。
用途特点:(参考课本4-5页)
2、答:
代码是一行或几行命令。
程序是针对某个任务编写的有序代码的集合。
软件是程序和文档的集合。
它们的关系是:代码 < 程序 < 软件
3、答ห้องสมุดไป่ตู้
面向对象程序设计中的每一个对象都应该能够接受数据、处理数据并将数据传达给其它对象,因此它们都可以被看作一个小型的“机器”,即对象。它能够让人们更简单地设计并维护程序,使得程序更加便于分析、设计、理解。
3、答
结果为:标签里显示一个“abc”,图片框里显示3行“欢迎您”。
4、答
要保存2次,分别是工程文件.vbp和窗体文件.frm。
4、答:
参考课本第9页
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
郑州大学VB实验报告书参考答案。
以下内容均来自百度文库,所以仅供参考。
不过经亲自测试习题及实验(一)的答案基本正确,除了实验题的3,4小题没有改字形字体颜色什么的。
实验一一、选择题DDBAB,C(CD)DDC,ADDCA二、填空题Windows中断工具箱代码分类form2.show有语法错误错误事件结构化文件名和结构工程编写代码双击任意控件或右健快捷菜单选“代码窗口”vb的安装文件夹属性方法fontload对象三、编程1-1Private Sub Command1_Click() Print Sqr(8), 8 ^ (1 / 3)End Sub1-2Private Sub Command2_Click() For i = 100 To 110Print Sqr(i)Next iEnd Sub1-3(基本设置在属性窗口完成!)Private Sub Command3_Click() Print "郑州大学在前进!"End Sub1-4(基本设置在属性窗口完成!)Private Sub Command4_Click() Label1 = "蓝天、白云、绿水、青山" End Sub实验二一BCBCC,CBBDA,CCCBA,CBDCC 二form_click()interval,5000vbp,frmtop,left,height,width,像素pictureloadlockedfont,alignmentgotfocus,lostfocus属性窗口,代码三2-1Private Sub Command1_Click() Label3 = Text1 * Text2End SubPrivate Sub Command2_Click() Label3 = Text1 / Text2End Sub2-2Private Sub Command1_Click() Picture1.Visible = TruePicture1 = LoadPicture("C:\Documentsand Settings\All Users\Documents\My Pictures\示例图片\Water lilies.jpg")End SubPrivate Sub Command2_Click()Picture1.Visible = TruePicture1 = LoadPicture("C:\Documentsand Settings\All Users\Documents\My Pictures\示例图片\Winter.jpg")End SubPrivate Sub Command3_Click()Picture1.Visible = FalseEnd Sub2-3Private Sub Command1_Click()Label3 = Text1 * Text2End Sub2-4Private Sub Command1_Click()Text2 = Text1End SubPrivate Sub Command2_Click()Text1 = ""Text2 = ""End SubPrivate Sub Text1_Change()Command1.Visible = TrueCommand2.Visible = TrueEnd Sub2-5Private Sub Command1_Click()Timer1.Interval = 500End SubPrivate Sub Command2_Click()Timer1.Interval = 0End SubPrivate Sub Timer1_Timer()Image1.Left = Int(Rnd * (Form1.ScaleWidth -Image1.Width)) Image1.Top = Int(Rnd * (Form1.ScaleHeight -Image1.Height)) End Sub实验三一A(BC)(BC)AA,A(BCD)DBB,B二3,4,5,6,8,10,11,12,14,15,16三abs(x+y)(3+x*y)^2(-b+sqr(b^2-4*a*c)/(2*a)sin(30*3.14/180)+exp(2)四int(rnd*71+20)x*y<0x mod 3=0 or xmod 7=0x>=10 and x<20x>="A" and x<="Z"left(s,3) 或者,mid(s,1,3)五3-2Private Sub Command1_Click()Dim x As Singlex = Val(Text1)Print Format(x ^ 2, "##.000"),Format(Sqr(x), "##.000"), Format(x ^ 3, "##.000"), Format(x^ (1 / 3), "##.000")End Sub3-3Private Sub Command1_Click()Dim x As Integerx = Int(Rnd * 900 + 100)Text1 = Trim(Str(x))Text2 = Right(Text1, 1) + Mid(Text1, 2, 1)+ Left(Text1, 1)End Sub3-4Private Sub Command1_Click()Dim max, min As Integermin = Val(Text1)max = Val(Text2)RandomizePrint Int(Rnd * (max - min + 1) + min),Int(Rnd * (max - min + 1) + min), Int(Rnd * (max - min + 1) + min)End Sub3-5Private Sub Command1_Click()Text1 = DateText2 = TimeText3 = WeekdayName(Weekday(Date)) End Sub实验四一CDCDA,DBBAC二(1) 48.71E-01,-4.8712(2) 关系,逻辑,数值(3) 900,100,mid(a,2,1),c(4)m1,2,3print m & "月是第二季度"end select三(1) x=4 y=13(2) 10四4-1Private Sub Command1_Click()Dim num, a1, a2, a3 As Singlenum = Val(Text1) * 180 / 3.14a1 = Int(num)num = num - a1a2 = Int(num * 60)num = num * 60 - a2a3 = Format(num * 60, "##.000")Print a1, a2, a3End Sub4-2Private Sub Command1_Click()Dim y As Integery = Val(Text1)If (y Mod 400 = 0 Or y Mod 4 = 0 And y Mod100 <> 0) Then MsgBox y & "是闰年"ElseMsgBox y & "不是闰年"End IfEnd Sub4-3Private Sub Command1_Click()Dim x, y, z, t As Integerx = Val(InputBox("input x:"))y = Val(InputBox("input y:"))z = Val(InputBox("input z:"))If x > y Then t = x: x = y: y = tIf y > z Thent= y: y = z: z = tIf x > y Then t = x: x = y: y = tEnd IfPrint x, y, zEnd Sub4-4Private Sub Command1_Click()Dim nettime As Integer, money As Singlenettime = Val(InputBox("每月上网时数:", "上网费用")) If nettime = -1 Thenmoney = 0ElseIf nettime < 10 Thenmoney = 25ElseIf nettime < 50 Thenmoney = nettime * 2ElseIf nettime < 100 Thenmoney = nettime * 1.5ElseIf nettime < 200 Thenmoney = nettimeElsemoney = 200End IfIf money <> 0 Then MsgBox "该月上网费用为" & money &"元"实验五一BCBAC二(1)for x=1 to 10s*(1-1/x)(2)t<1E-6(3)jt(4)5三5-1Private Sub Command1_Click()Dim i, sum As Integersum = 0For i = 1 To 100sum = sum + iNext iPrint "1+2+...+100="; sumEnd Sub5-2Private Sub Command1_Click()Dim x, y As IntegerFor x = 0 To 20For y = 0 To 33If 5 * x + 3 * y + (100 - x - y) / 3 = 100 ThenPrint x, y, 100 - x - yEnd IfNext yNext x5-3Private Sub Command1_Click()Dim i As Integeri = 7DoIf i Mod 2 = 1 And i Mod 3 = 2 And i Mod 5= 4 And i Mod 6 = 5 And i Mod 7 = 0 ThenPrint iExit DoElsei= i + 7End IfLoopEnd Sub5-4Private Sub Command1_Click()Dim x, y, z As IntegerFor x = 1 To 9For y = 1 To 9For z = 0 To 9If 100 * x + 10 * x + z + 100 * y + 10 * z + z = 532 Then Print x, y, zEnd IfNext zNext yNext xEnd Sub5-5Private Sub Command1_Click()Dim sum As Single, n As Integersum = 1Do While sum <= 4sum = sum * 1.1n= n + 1LoopPrint "经过"; n; "年销售收入翻两番"End Sub5-6Private Sub Command1_Click() Dim sum, i, n As Integersum = 0n = Val(InputBox("请输入n的值:")) For i = 1 To nsum = sum + i * (-1) ^ (i + 1) Next iPrint "1-2+3-4+...="; sumEnd Sub5-7Private Sub Command1_Click() Dim sum, isum, i, n As Integer sum = 0isum = 0n = Val(InputBox("请输入n的值:")) For i = 1 To nisum = isum + isum = sum + isumNext iPrint "1+(1+2)+(1+2+3)+...="; sum End Sub5-8Private Sub Command1_Click() Dim pi, ti As SingleDim i As Integerpi = 0ti = 1i = 1Do While Abs(ti) >= 0.0001ti = (-1) ^ (i + 1) / (2 * i - 1)pi = pi + tii= i + 1LoopEnd Sub5-9Private Sub Command1_Click()Dim i, j, k As IntegerPrint "水仙花数有:"For i = 1 To 9For j = 0 To 9For k = 0 To 9If i * 100 + j * 10 + k = i ^ 3 + j ^ 3+ k ^ 3 Then Print i, j, kEnd IfNext kNext jNext iEnd Sub5-10Private Sub Command1_Click()Dim i, j, k As Integerk = 0For i = 999 To 100 Step -1For j = 2 To Int(Sqr(i))If i Mod j = 0 Then Exit ForNext jIf j = Int(Sqr(i)) + 1 Then k = k + 1: Print i If k = 3 Then Exit ForNext iEnd Sub5-11Private Sub Command1_Click()Dim i, n, min, max As IntegerDim aver As Singlemin = 100max = 50For i = 1 To 20n= Int(Rnd * (99 - 51) + 51)Print n;If i Mod 5 = 0 Then PrintIf n > max Then max = nIf n < min Then min = naver = aver + nNext iPrint "max="; maxPrint "min="; minPrint "average="; aver / 20 End Sub5-12Private Sub Command12_Click() Dim i, j As IntegerFor i = 1 To 5For j = 1 To (2 * i - 1)Print Tab(20 - i + j); "*"; Next jNext iEnd Sub实验六一BCCCD DDDCA二、6-1Option Base 1Private Sub Command1_Click() Dim ia(10) As IntegerDim Max, min, aver As Integer, iMax, iminAs Integer For i = 1 To 10ia(i) = Int(Rnd * 51 + 50)Print ia(i);Next iPrintMax = ia(1): iMax = 1min = ia(1): imin = 1aver = ia(1)For i = 2 To 10aver = aver + ia(i)If ia(i) > Max Then Max = ia(i): iMax = iIf ia(i) < min Then min = ia(i): imin = iNext iPrint "max="; Max,"imax="; iMaxPrint "min="; min,"imin="; iminPrint "aver="; aver / 10End Sub6-2Private Sub Command1_Click()Dim ia(20), num(5) As IntegerDim Max, min, aver As Integer, iMax, iminAs IntegerFor i = 1 To 20ia(i) = Int(Rnd * 101)Print ia(i);Select Case ia(i)Case Is < 60num(1) = num(1) + 1Case60 To 69num(2) = num(2) + 1Case 70 To 79num(3) = num(3) + 1Case 80 To 89num(4) = num(4) + 1Case 90 To 100num(5) = num(5) + 1End SelectNext iPrintPrint "各分数段的人数分别是(0~59,60~69,70~79,80~89,90~100):" For i = 1 To 5Print num(i);End Sub6-3Private Sub Command1_Click()Dim a(10) As Integer, t%For i = 1 To 10a(i) = Int(Rnd * 51)Print a(i);Next iPrintFor i = 1 To 9For j = i + 1 To 10Ifa(i) < a(j) Then t = a(i): a(i) = a(j): a(j) = t Next jNext iPrint "排序后:"For i = 1 To 10Print a(i);Next i6-4Private Sub Command1_Click() Dim a(20) As Integer, t%For i = 1 To 20a(i) = Int(Rnd * 51)Print a(i);If (i + 1) Mod 5 = 0 Then Print Next iEnd Sub6-5Private Sub Command1_Click() Dim a(9), b(3, 3) As Integer, s%, t% For i = 1 To 9a(i) = Int(Rnd * 101)Print a(i);Ifi Mod 3 = 0 Thent = 3: s = i / 3Elset = i Mod 3: s = i \ 3 + 1 End Ifb(s, t) = a(i)Next iPrintFor i = 1 To 3For j = 1 To 3Print b(i, j);Next jPrintNext iEnd Sub6-6Private Sub Command1_Click() Dim a() As Integern = InputBox("n=?")ReDim a(n, n)For i = 1 To nFor j = 1 To na(i, j) = Int(Rnd * 10)Print a(i, j);Next jPrintNext iEnd Sub6-7Private Sub Command1_Click() Dim a() As Integern = InputBox("n=?")ReDim a(n, n)For i = 1 To na(i, i) = 1Next iFor i = 1 To nFor j = 1 To nPrint a(i, j);NextjPrintEnd Sub6-8Private Sub Command1_Click()Dim ia() As IntegerDim Max As Integer, iMax, jmax As Integerm = InputBox("m=?")n = InputBox("n=?")ReDim ia(m, n)Max = 0: iMax = 0: jmax = 0For i = 1 To mFor j = 1 To nia(i, j) = Int(Rnd * 101)Print ia(i, j);If ia(i, j) > Max Then Max = ia(i, j): iMax = i: jmax = j Next jPrintNext iPrint "max="; Max,"imax="; iMax, "jmax="; jmax实验七一CCDAB DDAAA二(1)n!(2)1到n累加和(3)n是否是素数(4)冒泡排序(5)递归调用实现斐波那契数列(6)求最大公约数和最小公倍数三7-1Private Sub Command1_Click() Dim n, sum As Integern = Val(InputBox("n=?"))sum = jsh(n)Print "1!+2!+...+"; n;"!="; sum End SubPublic Function jsh(n) As Integer Dim i, s, t As Integers = 0t = 1For i = 1 To nt= t * is= s + tNext ijsh = sEnd Function7-2Private Sub Command1_Click()Dim n, flag As Integern = Val(InputBox("n=?"))flag = 1sushu n, flagPrint "n="; flagEnd SubPublic Sub sushu(n, flag)Dim i As IntegerFor i = 2 To n - 1If n Mod i = 0 Then flag = 0: Exit For Next iEnd Sub7-3Private Sub Command1_Click()Dim flag As Integer, str As Stringstr = InputBox("n=?")flag = huiwen(str)If flag = 1 Then Print str; "是回文数" Else Print str; "不是回文数" End SubPublic Function huiwen(str) As IntegerDim lens, m, i As Integerlens = Len(str)For i = 1 To Int(lens / 2)If Mid(str, i, 1) <> Mid(str, lens - i + 1, 1) Then Exit For Next iIf i = Int(lens / 2) + 1 Then huiwen = 1Else huiwen = 0End Function7-4Private Sub Command1_Click()Dim n, m, c1, c21, c22, c23 As Integer n = Val(InputBox("n=?"))m = Val(InputBox("m=?"))c1 = jc1(n) / (jc1(m) * jc1(n - m))Print "函数计算c1="; c1jc2 n, c21jc2 m,c22jc2 n - m, c23Print "子过程计算c2="; c21 / (c22 * c23) End SubPublic Sub jc2(n, c)Dim i As Integerc = 1For i = 1 To nc= c * iNext iEnd SubPublic Function jc1(n)Dim i As Integers = 1For i = 1 To ns= s * iNext ijc1 = sEnd Function7-5Private Sub Command1_Click() Dim str1 As Stringstr1 = InputBox("请输入一个实数:") MsgBox sum(str1)End SubPublic Function sum(str As String) Dim lens, i, n As IntegerDim c As String * 1lens = Len(str)n = 0c= Mid(str, i, 1)If c <= "9" And c >= "0" Thenn = n + Val(c)End IfNext isum = nEnd Function7-6Private Sub Command1_Click()Dim str1 As Stringstr1 = InputBox("请输入一个字符串:") Print str1; "中有数字字符"; num(str1); "个。