第一章 VB开发环境与VB概述 习题答案
习题
一、选择题 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. B C
A D A A B D D B A A C B 11. 12. 13. 14. 第二章 常用控件与界面设计 习题答案
习题
一、选择题 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. C B B B B D 61. B B B B C A D C D B B B C A A C B B D A B C D D D B B C B A C B B 27. A D A 57. A B C B D B C C C B B D C C D C A C B 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 28. 29. 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. 58. 59. 60. 第三章实验与习题
实验
实验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. D 11. D 21. D 31. B 41. B 51. C 61. B 71. C 81. C
2. B 12. D 22. C 32. C 42. C 52. B 62. B 72. B 82. B 3. B 13. D 23. D 33. A 43. B 53. D 63. C 73. B 83. D 4. D 14. C 24. A 34. D 44. D 54. D 64. A 74. D 84. B 5. B 15. D 25. A 35. A 45. C 55. D 65. B 75. D 85. B 6. D 16. D 26. B 36. B 46. C 56. A 66. B 76. C 86. B 7. D 17. B 27. A 37. B 47. A 57. B 67. D 77. B 87. A 8. B 18. A 28. A 38. B 48. D 58. A 68. A 78. D 88. D 9. C 19. D 29. C 39. C 49. B 59. A 69. A 79. A 89. C 10. A 20. B 30. A 40. D 50. A 60. A 70. A 80. D 填空题
1、2 -32768~32767
2、整型 长整型 单精度 双精度 3、0 False “”
4、Chr(Int(Rnd*(Asc(“L”)-Asc(“C”))+Asc(“C”))) x>0 And y>0 Or x<0 And y<0
c>=”a” And c<=”z” Or c>=”A” And c<=”Z” x>=10 And x<20 x True True True 6、188 200100 68.56 876554 7、a=1 b=1 a=2 b=1 a=3 b=1 a=4 b=1 8、Y Mod 4=0 And Y Mod 100<>0 Or Y Mod 400 =0 9、He Said, “Good morning”. 10、EDEF 11、(A>0 And A<>Int(A)) And (B<0 And B<>Int(B)) 12、a+b+c+d (a+b+c+d)/4 sum aver 13、(f-2*h)/2 (4*h-f)/2 简答题 1、略 2、Private Sub Form_Click() Const g = 9.8 Dim V0 As Single, t As Single Dim S As Single V0 = InputBox(\请输入V0的值:\ t = InputBox(\请输入时间t的值:\ S = (1 / 2) * g * t ^ 2 + V0 * t MsgBox (\位移量为:\End Sub 3、Private Sub Command1_Click() Dim l As Single, w As Single, h As Single Dim s As Single l = Text1.Text w = Text2.Text h = Text3.Text s = (l * w + l * h + w * h) * 2 Label1.Caption = s