VB编程实验报告答案 完整版.doc

上传人:飞****2 文档编号:56542581 上传时间:2022-11-02 格式:DOC 页数:19 大小:86.50KB
返回 下载 相关 举报
VB编程实验报告答案 完整版.doc_第1页
第1页 / 共19页
VB编程实验报告答案 完整版.doc_第2页
第2页 / 共19页
点击查看更多>>
资源描述

《VB编程实验报告答案 完整版.doc》由会员分享,可在线阅读,更多相关《VB编程实验报告答案 完整版.doc(19页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、实验一:一、选择1.D 2.D 3.B 4.A 5.B 6.C 7.CD 8.D 9.D 10. BC11. A 12.D 13. D 14. C 15. A二、填空1.windows 2. 中断 3.工具箱 4.代码 5.分类6.form2.show 7. 出现语法错误 8. 错 9. 事件 10. 面向对象 11.工程文件结构 12. 工程 13. 设计程序代码 14. 双击窗体 15. C:Program FilesMicrosoft Visual StudioVB98 或者 VB的安装文件夹 16.属性 17.方法 18.font 19. form_load() 20.对象实验二:一、

2、选择1.B 2.C 3. B 4.C 5.C 6.C 7.B 8.B 9.D 10. A11. C 12.C 13. C 14. B 15. A16.C 17.B 18.D 19.C 20. C二、填空1. Form_Click() 2. Interval、5000 3.vbp .frm 4.left top Height、Width twip 5.picture 6.load 7. locked 8. font Alignment 9. GotFocus() LostFocus() 10. 属性窗口 程序代码实验三:一、选择1.A 2.BC 3.BC 4.A 5.A 6.A 7.BCD 8.

3、D 9.B 10. B11. B 二、判断题不合法的变量: 3. 4. 5. 6. 8. 10. 11. 14.15. 16. 三、1、abs(x+y)2. (3+x*y)23. (-b+sqr(b2-4*a*c)/(2*a)4.sin(30*3.14/180)+exp(2)四、1. int(rnd* 71+20) 或int(rnd* 71)+202. x0 or x0 and y0 或者x*y=10 and x=A and x1E-6(3) j t(4) 5 11 5实验六一、选择B C C C D D D D C A实验七一、选择1C 2C 3D 4A 5B 6D 7AB 8A 9A 10

4、A二、填空(1)n!(2)1+1+2+3+4+n(3)n是否是素数(4)冒泡排序(5)递归调用产生斐波那契数列(6)求最大公约数和最小公倍数 第八页编程2-1Private Sub Command1_Click()Label3 = Val(Text1) * Val(Text2)End SubPrivate Sub Command2_Click()Label3 = Val(Text1) / Val(Text2)End Sub2-2Private Sub Command1_Click()Picture1.Picture = LoadPicture(d:tu1.jpg)End SubPrivate

5、Sub Command2_Click()Picture1.Picture = LoadPicture(d:tu2.jpg)End SubPrivate Sub Command3_Click()Picture1.Visible = FalseEnd Sub2-5Private Sub Form_Load()Image1.Picture = LoadPicture(C:Documents and SettingsAll UsersDocumentsMy Pictures示例图片Sunset.jpg)End SubPrivate Sub Command1_Click() Timer1.Enabled

6、 = TrueEnd SubPrivate Sub Command2_Click() Timer1.Enabled = FalseEnd SubPrivate Sub Image1_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第11页编程2-3Private Sub Comm

7、and1_Click() Dim x%, y% x = Int(Rnd * 900 + 100) Print 产生的随机数:; x y = (x Mod 10) * 100 + (x 10 Mod 10) * 10 + x 100 Print 反序数:; Format(y, 000)End SubPrivate Sub Command2_Click() Dim x%, y As String x = Int(Rnd * 900 + 100) Print 产生的随机数:; x y = Trim(Str(x) Print 反序数: & Right(y, 1) & Mid(y, 2, 1) & Le

8、ft(y, 1)End SubPrivate Sub Form_Load()End Sub 2-4Private Sub Command1_Click()Dim m%, n%Randomizem = Val(Text1): n = Val(Text2)x = Int(Rnd * (n - m + 1) + m)y = Int(Rnd * (n - m + 1) + m)z = Int(Rnd * (n - m + 1) + m)Label3 = m & 到 & n & 之间的3个随机数为: & x & Space(3) & y & Space(3) & zEnd SubPrivate Sub

9、Form_Load()End Sub2-5Private Sub Command1_Click()Label1.Caption = DateEnd SubPrivate Sub Command2_Click()Label2.Caption = TimeEnd SubPrivate Sub Command3_Click()Label3.Caption = WeekdayName(Weekday(Date)End SubPrivate Sub Form_Load()End Sub第十五页2-1方法一Private Sub Command1_Click() Dim x!, a!, aa%, b!,

10、bb%, c!, cc$ x = Val(Text1) a = x * 180 / 3.14 aa = Int(a) b = (a - aa) * 60 bb = Int(b) c = (b - bb) * 60 cc = Format(c, #.000) Label2 = 弧度 & Text1 & 转换为 & aa & 度 & bb & 分 & cc & 秒End Sub方法二Private Sub Command1_Click() x = InputBox(请输入弧度数值, 弧度转换, 0) xx = Val(x) a = x * 180 / 3.14 aa = Int(a) b = (a

11、 - aa) * 60 bb = Int(b) c = (b - bb) * 60 cc = Format(c, #.000) MsgBox 弧度 & x & 转换为 & aa & 度 & bb & 分 & cc & 秒End Sub2-2Private 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 & 年是闰年Else Label2 = Text1 & 年不是闰年End IfEnd Sub2-3方法二Private Su

12、b Command1_Click()Dim x%, y%, z%x = InputBox(输入第一个数)y = InputBox(输入第二个数)z = InputBox(输入第三个数)If x y Then t = x: x = y: y = tIf y z Then t = y: y = z: z = tIf x y Then t = x: x = y: y = tPrint x, y, zEnd SubPrivate Sub Form_Load()End Sub方法一Private Sub Command1_Click()Dim x%, y%, z%x = Val(Text1)y = Va

13、l(Text2)z = Val(Text3)If x y Then t = x: x = y: y = tIf y z Then t = y: y = z: z = t If x y Then t = x: x = y: y = t End IfEnd IfLabel1 = x & Space(5) & y & Space(5) & zEnd Sub2-4方法一Private Sub Command1_Click()x = Val(InputBox(请输入上网时间:)If x -1 Then Select Case x Case Is = 100 fei = x * 1 End Select

14、MsgBox 上网费用为: & fei & 元End IfEnd SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Form_Load()End Sub方法二Private Sub Command1_Click()Dox = Val(InputBox(请输入上网时间:, , -1)If x -1 Then Select Case x Case Is = 100 fei = x * 1 End Select zongfei = zongfei & Space(3) & fei MsgBox zongfei, , 上网费用为Else Exit

15、 DoEnd IfLoopEnd SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Form_Load()End Sub2-5 第18页2-3Private 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 Sub2-5Private Sub Command1_Click()x = Val(Text1)y =

16、 x * 4n = 0Do While x = 0.0001 s = s + (-1) (n + 1) * 1 / (2 * n - 1) n = n + 1Looppi = 4 * sPrint piEnd Sub2-9Private Sub Command1_Click()For n = 100 To 999k = Trim(Str(n)If n = Left(k, 1) 3 + Mid(k, 2, 1) 3 + Right(k, 1) 3 Then Print nNextEnd Sub2-11Private Sub Command1_Click()s = 0: Max = 0: Min = 1000For i = 1 To 20Randomizex = Int(Rnd * 50 + 51)Print x;If x Max Then Max = xIf x Min Then Min = xs = s + xNext iaver = s / 20PrintPrint max=; Max, min=; Min, aver=; averEnd SubPrivate Sub Form_Load()End Sub

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁