1、大学VB实验教材的实验与习题答案第一章 VB开发环境与VB概述 习题答案习题一、选择题1. 2. 3. 4. 5. 6. 7. 8. 9. 10. BAABDBAACB11. 12. 13. 14. CDAD第二章 常用控件与界面设计 习题答案习题一、选择题1. 2. 3. 4. 5. 6. 7. 8. 9. 10. CBCAABBBCC11. 12. 13. 14. 15. 16. 17. 18. 19. 20. BBDABBBCCD21. 22. 23. 24. 25. 26. 27. 28. 29. 30. BBBCCCABBC31. 32. 33. 34. 35. 36. 37. 38
2、. 39. 40. BCBBDBDDBA41. 42. 43. 44. 45. 46. 47. 48. 49. 50. BABBDAABDC51. 52. 53. 54. 55. 56. 57. 58. 59. 60. DDCDDCACCB61. B第三章实验与习题实验实验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 Singl
3、e 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) +
4、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(Visual Basic, 1, 12) = Right(Langu
5、age Visual Basic, 12) List1.AddItem ABCRG = abcde List1.AddItem Int(134.69) = CInt(134.9) List1.AddItem 78.9 / 32.77 -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:
6、C3 = 90 x = 9: y = -2 List1.Clear List1.AddItem x + y 0 List1.AddItem (x% = 0 And y% = 0) Or (x% 0 And y% = 255 Or C1 90 And C2 90 And C3 80End 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(请输入商品的单价:
7、, 单价框) sl = InputBox(请输入商品的数量:, 数量框, 1) je = dj * sl n = MsgBox(共计金额= & je, vbOKCancel + vbInformation, 结果) If n = vbOK Then Label1.Caption = 金额: & Str(je) & 元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):
8、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 = 结果为: & Str(x1) & Str(x2) & Str(x3) End Sub求逆序数Private Sub Command3_Click() Dim a As Integer, h As Integer, t As Integer, n As Integer Randomize a = Int(Rnd * (999
9、 - 100 + 1) + 100) h = Mid(CStr(a), 1, 1) t = Mid(CStr(a), 2, 1) n = Right(CStr(a), 1) Label5.Caption = a & - & Format(n * 100 + t * 10 + h, 000)End Sub实验3_5略习题选择题1. 2. 3. 4. 5. 6. 7. 8. 9. 10. DBBDBDDBCA11. 12. 13. 14. 15. 16. 17. 18. 19. 20. DDDCDDBADB21. 22. 23. 24. 25. 26. 27. 28. 29. 30. DCDAAB
10、AACA31. 32. 33. 34. 35. 36. 37. 38. 39. 40. BCADABBBCD41. 42. 43. 44. 45. 46. 47. 48. 49. 50. BCBDCCADBA51. 52. 53. 54. 55. 56. 57. 58. 59. 60. CBDDDABAAA61. 62. 63. 64. 65. 66. 67. 68. 69. 70. BBCABBDAAA71. 72. 73. 74. 75. 76. 77. 78. 79. 80. CBBDDC BDAD81. 82. 83. 84. 85. 86. 87. 88. 89. CBDBBBADC
11、填空题1、2 -32768327672、整型 长整型 单精度 双精度3、0 False “”4、Chr(Int(Rnd*(Asc(“L”)-Asc(“C”)+Asc(“C”) x0 And y0 Or x0 And y=”a” And c=”A” And c=10 And x20 xz Xor yz5、False 2 True False True True True True6、188 200100 68.56 8765547、a=1 b=1 a=2 b=1a=3 b=1 a=4 b=18、Y Mod 4=0 And Y Mod 1000 Or Y Mod 400 =09、He Said,
12、“Good morning”.10、EDEF11、(A0 And AInt(A) And (B0 And BInt(B)12、a+b+c+d(a+b+c+d)/4sumaver13、(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 (位移量为: & S)End Sub3、Priv
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1