VISUAL BASIC6.0程序设计教程(第三版)课后习题答案罗朝盛主编人民邮电出版社
更新时间:2023-12-16 07:49:01 阅读量: 教育文库 文档下载
VB课后习题答案
二、选择题
1. C 2. B
第2章 习题参考答案
一、判断题
题号 1 2 3 4 5 6 7 8 9 10 11 答案 × × √ √ × √ × √ √ √ √ 二、填空题 1. 窗体font
2. 不能在代码中设置 3. selstart
4. Locked
5. TabIndex 、 0
6. vbModal或 1
7. Activate 、 Deactivate 8. PictureBox 和 Frame -
三、选择题 题号 答案
1 D 2 C 3 D 4 A 5 D 6 B 7 B 8 B 9 A 10 B 第3章 习题参考答案
一、思考题
1、double
2、 xyC@abc, 15eyd, Is, #END X8[P] 3、变量有 (1) (4) (6) (8),
常量有 (2)字符串型 (3)逻辑型 (5)字符串型 (7)字符串型 (9)日期型 (10)实型 4、
b?d?acef
5、 (1) 26 (2) 3.75 (3) 3 6、写出下列Visual Basic表达式的值:
(1) False (2) True (3) True (4) False (5) True (6) True (7) False (8) False
7、将下列命题用Visual Basic布尔表达式表示:
(1) z>x and z>y
(2) abs(a)<=abs(b+2) or a > b+2
(3) p mod q=0 (4) x<-5 or x>-2 and x<2 or x>5
(5) x (1) -4 (2) 换行符 (3) –3 (4) -1 (5) hello (6) ello (7) 16 (8) “-459.65” (9) 5 二、填空题 1. 整型 、 长整型 、 双精度型 、 双精度型 2. (X mod 10)*10+X\\10 3. sin(1/4*3.14)+sqr(x+2*exp(y))/abs(x-y) 4. (a+b)/(c*d-sqr(1-a^2)) 5. x mod 5=0 or x mod 9=0 6. False 7. -3 、 2 、 -2 、 2 8. CDEF 9. x>0 and y>0 or x<0 and y<0 或 x*y>0 10. s>=”A” and s<=”Z” or s>=”a” and s<=”z” 三、选择题 题号 1 答案 C 四、编程题 1、 Private Sub Form_Click() Dim x%, Ten%, hundred% x = Val(Text1.Text) 2 Private Sub Form_Click() Dim char As String * 1 Form1.CurrentX = Rnd * Form1.ScaleWidth Form1.CurrentY = Rnd * Form1.ScaleHeight char = Chr(Int(Rnd * 16) + 65) Print char End Sub 2 B 3 B 4 B 5 D Ten = (x \\ 10) Mod 10 hundred = x \\ 100 Print \百位数是: \Print \十位数是: \ End Sub 第4章 习题参考答案 一、判断题 题号 1 答案 × 2 × 3 × 4 √ 5 √ 6 √ 7 √ 8 × 二、选择题 题号 答案 1 A 2 D 3 B 4 B 5 B 三、程序阅读 写出下列各段程序执行后的输出结果。 1.78 5786 357864 13578642 2. w=4、w=13、w=135、w=31 3.此题有点错误,修改如下: 是将语句“If k < Asc(\”改为: If k < Asc(\ 改后的答案: xyza12 uvw& 4.A BBB CCCCC DDDDDDD EEEEEEEEE 5.此题的“IF KeyAsci=13 Then”改为“IF KeyAscii=13 Then” 答案是:129 四、程序填空题 1. (1) Sing=-1 (2) For i=2 to 19 (3) Sing=-Sing 2. (1) Len(oldsen) (2) Mid(oldsen ,i,1) (3) Ucase(char) (4) char 3. (1) Len(str1) (2) Length-1 (3) Mid(str1,i,2) (4) Sum=0 4. (1) Trim(Str(i)) (2) Trim(Str(i*i)) (3) Right(x2,Len(x1))=x1 5. (1) last_one = last_two (2) last_two = this_one (3) i = i+1 (4) i-1 五、编程题 1. Private Sub Form_Click() Dim R1 As Double, R2 As Double 'R1,R2 表示两电阻值 Dim Rp As Double, Rs As Double R1 = Val(InputBox(\输入电阻R1=?\ R2 = Val(InputBox(\输入电阻R2=?\ Rp = R1 * R2 / (R1 + R2) Rs = R1 + R2 Rp = Fix(Rp * 1000 + 0.5) / 1000 '保留小数点后3位 Rs = Fix(Rs * 1000 + 0.5) / 1000 '保留小数点后3位 MsgBox \并联电阻是:\串联电阻是:\End Sub 2. Private Sub Form_Click() Dim N As Long N = Val(InputBox(\请输入年份\提示框\ If (N Mod 400 = 0) Or (N Mod 4 = 0 And N Mod 100 <> 0) Then '判断条件 Print N & \年是闰年\ Else Print N & \年不是闰年\ End If End Sub 3. Private Sub Form_Click() Dim a!, b!, c!, s!, x! a = Val(InputBox(\ b = Val(InputBox(\ c = Val(InputBox(\ If a + b > c And b + c > a And a + c > b Then '如果能构成三角形 x = (a + b + c) / 2 s = Sqr(x * (x - a) * (x - b) * (x - c)) Print \ Else Print \数据有错,不能构成三角形\ End If End Sub 4.(此题不适合使用Select语句) Private Sub Command1_Click() Dim x As Double, fx As Double x = Val(InputBox(\输入x=?\ If x < 0 And x <> -3 Then fx = x * x + x - 6 ElseIf x >= 0 And x < 10 And x <> 2 And x <> 3 Then fx = x * x - 5 * x + 6 Else fx = x * x - x - 1 End If Print \ f(\End Sub 5. Dim i As Integer Dim s As Long, t As Long t = 1 For i = 1 To 10 t = t * i s = s + t Next i Print \ S=\6. Dim i%, s!, n!, t!, f% 二、选择题 题号 答案 1 D 2 C 3 A 4 D 5 B 三、程序填空题 1.(1) nsp=true (2) m mod i=0 (3) p1 and p2 (4) p1=nsp(i) 2.(1) number(i,7) (2) (int n, int m) (3) number=number*10+m 四、程序阅读 1. a=9 b=4 2.(1) 36 25 16 9 4 1 (2) 1 4 9 9 4 1 3. 6 4. 1 4 6 五、编写程序 1. Public Function fact(x As Integer) As Single Dim f As Single, i As Integer f = 1 For i = 1 To x f = f * i '累积 Next i fact = f End Function Private Sub Form_Click() Dim n%, m%, y! Do '求x! m% = Val(InputBox(\ n% = Val(InputBox(\ Loop Until m >= n And n >= 0 y = fact(m) / (fact(n) * fact(m - n)) Print y End Sub 2 private sub Insertfun(a%(), y%) Dim i as integer,n as integer n=ubound(a) Redim preserve a(n+1) For i=ubound(a)-1 to 0 step -1 If y If i=0 then a(i)=y Else a(i+1)=y exit for end if next i 3. '判断是否为回文函数 Private Function Judge(str As String) As Boolean Dim i As Integer Judge = True '假设为回文 For i = 1 To Len(str) \\ 2 '依次判断对应位置的两个字符,只要有一组不等即不是回文 If Mid(str, i, 1) <> Mid(str, Len(str) + 1 - i, 1) Then Judge = False Exit Function End If Next i End Function 4. Private Sub Form_Click() Dim n%,x! n = Val(InputBox(\ x = Val(InputBox(\ Print fe(n, x) '调用求值函数过程 End Sub '求值函数过程 Public Function fe(n%, x!) As Single Dim i As Integer, t As Single fe = 1: t = 1 For i = 1 To n t = t * x / i 't为通项 fe = fe + t Next i End Function 5.。。。。 第7章 习题参考答案 一、判断题 题号 1 答案 × 2 × 3 √ 4 √ 5 × 6 × 7 × 8 √ 9 √ 10 √ 11 × 12 × 13 √ 14 √ 15 × 16 √ 二、填空题 1.___Multiline_______ 2.____Value______ 3.___Selected______、____List______、____0______、___List1.ListCount-1____ 4. 下拉式列表框 5.___LargeChange_______、____Value______ 6. Shift+Ctrl 7.KeyAscii=0 if KeyAscii>57 OR KeyAscii<48 then KeyAscii=0 三、程序填空 1. Label1.Font = Combo1.Text Combo2.Text Label1.FontBold = True Label1.FontItalic = True Label1.FontSize = Val(Combo3.Text) 2. List1.List(list1.ListIndex) list1.RemoveItem List1.ListIndex List1.AddItem List2.List(List2.ListIndex) List2.RemoveItem 四、选择题 题号 答案 1 A 2 D 3 D 4 B 5 D 6 D 7 C 8 D 五、编程题 1.'添加功能 Private Sub cmdAdd_Click() Dim i% If Combo1.Text = \ For i = 0 To Combo1.ListCount - 1 '逐个判断是否有与输入内容相同的项目 If Combo1.Text = Combo1.List(i) Then Exit Sub '找到相同项目则退出 Next i Combo1.AddItem Combo1.Text '未找到则添加 End Sub '删除功能 Private Sub cmdDelete_Click() If Combo1.ListIndex >= 0 Then '是否选中某一项目 Combo1.RemoveItem Combo1.ListIndex '删除选中项目 Else '删除与输入内容相同的项目 For i = 0 To Combo1.ListCount - 1 If Combo1.List(i) = Combo1.Text Then Combo1.RemoveItem i End If Next i End If End Sub '清除 Private Sub Command3_Click() Combo1.Clear End Sub 2. Private Sub Command1_Click() ‘ 产生随机数 Dim i% Randomize For i = 1 To 10 List1.AddItem Str(Int(Rnd * 90) + 10) Next i List2.Clear End Sub Private Sub Command2_Click() ‘ 迁移偶数 Dim i% i = 0 Do While i <= List1.ListCount - 1 If Val(List1.List(i)) Mod 2 = 0 Then List2.AddItem List1.List(i) List1.RemoveItem i Else i = i + 1 End If Loop End Sub 3. Private Sub List1_DblClick() Dim i As Integer For i = 0 To List2.ListCount - 1 '防止重复点歌 If List2.List(i) = List1.Text Then Exit Sub End If Next i List2.AddItem List1.Text End Sub Private Sub List2_DblClick() List2.RemoveItem List2.ListIndex End Sub 第10章 习题参考答案 一、判断题 题号 1 答案 √ 2 √ 3 √ 4 × 5 × 6 × 7 √ 8 √ 9 √ 10 √ 二、选择题 题号 答案 1 D 2 A 3 C 4 C 5 B 6 D 7 A 8 B 9 D 10 B 三、填空题 1. 2. 3. 4. 5. 窗体控件菜单、下拉菜单、快捷菜单 ___ShowFont___ ___打开/另存为、颜色、字体、帮助、打印 工程/部件、选中Microsoft Common Dialog Control 6.0 ___ CommonDialog1.Action =3、CommonDialog1.ShowColor ______
正在阅读:
VISUAL BASIC6.0程序设计教程(第三版)课后习题答案罗朝盛主编人民邮电出版社12-16
往年中国儿童慈善活动日专题活动11-29
华工网院《劳动法学》平时作业(2016下半年)-冯乐平10-09
2016年庆祝教师节晚会主持词09-01
导数的应用复习课 优秀教案06-04
教师招聘美术学科:美术史论知识复习策略05-05
云南的歌会说课稿11-26
金审学院政治经济学练习题05-18
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 人民邮电出版社
- 课后
- 习题
- 程序设计
- 主编
- 答案
- 教程
- VISUAL
- BASIC
- 罗朝盛
- 6.0