VB实验与习题答案 下载本文

内容发布更新时间 : 2024/11/1 8:18:43星期一 下面是文章的全部内容请认真阅读。

第一章 VB开发环境与VB概述 习题答案

习题

一、选择题

1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. B

A A B D B A A C B C D A D 第二章 常用控件与界面设计 习题答案

习题

一、选择题

15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. C B B A 75. B B B C A C C B B A C B D A D D C B B B D B B D D B B D C C C B D C C A D B C B C B A A A D B B C A B B C B C D B 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 第三章实验与习题

实验

实验3_1 ?算术运算

Private Sub Command1_Click()

Const a As Single = 3, b As Single = 2, c As Single = -1, d As Single = 6 Dim x As Single, y As Single, z As Single, m As Single x = 2: y = 1: z = 1: m = 1

List1.Clear

List1.AddItem a / (b + c / b)

List1.AddItem (x + Sqr(x ^ 2 + 1)) ^ (1 / 3)

List1.AddItem ((2 * y) / (a * x + b * y) * (a * x - b * y)) List1.AddItem 1 + 1 / (1 + 1 / m) List1.AddItem 1 / 2 * (d / 3) ^ (2 * x) List1.AddItem Log(y + Cos(x) ^ 2)

List1.AddItem Abs((Exp(x) + Sin(x) ^ 3) / (x + y))

List1.AddItem Log((Exp(x * y) + Abs(1 / Tan(z) + Cos(x) ^ 3)) / (x + y - z)) List1.AddItem Sin(45 * 3.1415 / 180) + (Exp(10) + Log(10)) / Sqr(x + y + 1) List1.AddItem Log(a) / Log(b) End Sub ?关系运算

Private Sub Command2_Click() List1.Clear

List1.AddItem Mid(\ List1.AddItem \ List1.AddItem Int(134.69) >= CInt(134.9)

List1.AddItem 78.9 / 32.77 <= 97.5 / 43.87 And -45.4 > -4.98 List1.AddItem Str(32.345) = CStr(32.345) End Sub ?逻辑运算

Private Sub Command3_Click() Dim x As Integer, y As Integer

Dim C1 As Integer, C2 As Integer, C3 As Integer C1 = 70: C2 = 80: C3 = 90 x = 9: y = -2 List1.Clear

List1.AddItem x + y < 10 And x - y > 0

List1.AddItem (x% >= 0 And y% >= 0) Or (x% < 0 And y% < 0)

List1.AddItem x = 0 Xor y = 0

List1.AddItem C1 + C2 + C3 >= 255 Or C1 > 90 And C2 > 90 And C3 > 80 End Sub 实验3_2 略

实验3_3 略

实验3_4 ?零售结算

Private Sub Command1_Click()

Dim dj As Single, sl As Single, je As Single, n As Integer Label1.Caption = \金额:\

dj = InputBox(\请输入商品的单价:\单价框\ sl = InputBox(\请输入商品的数量:\数量框\

je = dj * sl

n = MsgBox(\共计金额=\结果\ If n = vbOK Then Label1.Caption = \金额:\元\End Sub ?产生随机数

Private Sub Command2_Click() Dim m As Integer, n As Integer

Dim x1 As Integer, x2 As Integer, x3 As Integer m = Val(Text1.Text): n = Text2.Text Randomize

x1 = Int(Rnd * (n - m + 1) + m) x2 = Int(Rnd * (n - m + 1) + m) x3 = Int(Rnd * (n - m + 1) + m)

Label4.Caption = \结果为:\ End Sub ?求逆序数

Private Sub Command3_Click()

Dim a As Integer, h As Integer, t As Integer, n As Integer Randomize

a = Int(Rnd * (999 - 100 + 1) + 100) h = Mid(CStr(a), 1, 1) t = Mid(CStr(a), 2, 1) n = Right(CStr(a), 1)

Label5.Caption = a & \End Sub 实验3_5 略

习题 选择题

1-20: DBBDB DDBCA DDDCD DB_DB 21-40: DCDAA B_ACA BCADA B_BCD 41-60: BCBDC CADBA CBDDD ABAAA 61-80:BBCAB BDAAA CBBDD CBDAD 81-89:CBDBB BADC

填空题

1、2 -32768~32767