版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、vb课后习题答案第一章 习题参考答案一、 填空题1、对象 事件驱动2、编译运行模式 解释运行模式二、 简答题1、 简述vb的特点。答:可视化的程序设计方法面向对象的程序设计思想事件驱动的编程机制结构化的程序设计语言高度的可扩充性强大的数据库访问能力支持动态数据交换支持对象链接与嵌入2、简述vb的安装过程。答:向光驱中放入vb安装光盘;计算机将运行自动安装程序,若没有,执行vb目录下的setup.exe;根据提示逐一回答问题,并点击“下一步”;点击“完成”;2、 如何启动vb。答:三种方法:单击“开始”按钮,选择“程序”菜单下的“microsoft visual basic 6.0 中文版”菜单
2、项并单击;双击桌面上的vb6.0快捷图标;在“开始”菜单的运行对话框中输入命令来启动vb;第二章 习题参考答案一、选择题:1-10、 dcacd bcbbc11-20、badca bbaab21-29、aacbb cddc二、填空题1 窗体、控件2 属性值3 属性窗口设置、代码窗口设置4 事件过程5 对象名、下划线、事件名6 form_click第三章 习题参考答案一、选择题1、b 2、c 3、a 4、b 5、a 6、c 7、c二、填空题1、 11 字符型、字节型、整型、长整型、单精度型、双精度型、货币型、逻辑型、日期型、对象型、变体型。string、byte、integer、long、sin
3、gle、double、currency、boolean、date、object、variant2、 双引号(英文)、#3、 ascii、1、24、 public、通用、dim、static、private、static5、 &、+、+6、 now()、time、日期型三、解答题1、(3) 2、(1 )3、(1)常量(关键字) (2)字符型常量 (3)逻辑型常量 (4)变量 (5)字符串常量 (6)变量 (7)字符串常量 (8)变量 (9)日期型常量 (题目应是#11/16/1999#) (10)数值型常量(单精度) 4、315、(1)(1+y/x)/(1-y/x) (2)x3+3*x*
4、y/(2-y)(3)sqr(abs(a*b-c3) (4)sqr(s*(s-a)*(s-b)*(s-c)6、7、(1)13 (2)17(3)#1999-11-12# (4)zxy123abc8、(1)19 (2)8.16666666666667(3)525 (4)29、(1)-4 (2)2 . 82842712474619 (3)-3 (4)49 (5)”hello” (6)he 7)16 (8) “-459.65” (9)5 10、(4)11、(2)12、(4)第四章 习题参考答案一、选择题:17: daabbcd二、填空题1 500.00%2 将字号扩大为原来的二倍3 b三、编程题(略)1
5、文本框、标签和命令按钮的名称分别为text1、label1、command1private sub command1_click()label1.caption=text1.textcommand1.caption=text1.textend sub2单价、数量、折扣和应付款对应的文本框的名称分别为:text1、text2、text3和text4,计算和清除命令按钮的名称分别为:command1和command2。private sub command1_click()text4=val(text1)*val(text2)*val(text3)end subprivate sub comman
6、d2_click()text1=” : text2=”: text3=”: text4=” end sub3文本框、“转大写”命令按钮和“转大写”命令按钮的名称分别为text1、command1和command2private sub command1_click()text1=ucase(text1)end subprivate sub command2_click()text1=lcase(text1)end sub第五章 习题参考答案一、选择题:111: caabbabbbcc二、填空题1(3) 2 1 2 3 32 2 3 4160 59678 7x<=5 (或x<6 或
7、x<7) 8b9isum isum+j 1250三、编程题1private sub form_click()dim i%,s%s=0for i = 101 to 200 step 2if i mod 3<>0 thenprint is=s+iend ifnext iprint send sub2private sub form_click()dim n%,s&s=1:n=0while s<=400000n=n+1s=s*nwendif s>400000 then n=n-1print nend sub3private sub form_click()dim
8、 imin%,imax%,i%,r%imin=100:imax=20for i=1 to 20r=int(rnd*51+50)if r>imax then imax=rif r<imin then imin="r next iprint imax,iminend sub第六章 习题参考答案一、选择题:113: abaaccbadadbb二、填空题1interval label1.caption=time 2list1.listcount interval hscroll1.max三、编程题第七章 习题参考答案一、选择题:112: dcadd bbdac cb二、填空题14
9、2 2index 3414a(i)=a(11-i) a(11-i)=tmp51 6x mod 7=0 721080 to 8 i+1 to 993 k 110 1001 max maxmax)三、编程题1private sub c1_click()if op1(0).value=true then p1.print “选择了椭圆形”if op1(1).value=true then p1.print “选择了圆形”if op1(2).value=true then p1.print “选择了正方形”end sub2统计按钮名为command1,输入框名为text1,输出框为text2(mult
10、line设为true)private sub command1_click()dim x(1 to 26) as integer,i as integerdim s as string,l as integerl=len(text1.text)for i=1 to ls=mid(text1,i,1)s=ucase(s)if s >= "a" and s <= "z" thenx(asc(s) - 65 + 1) = x(asc(s) - 65 + 1) + 1end ifnext ifor i=1 to ltext2=text2 &
11、chr(64+i) & “=” & x(i) & “ “if i mod 7=0 then text2=text2 & chr(13)+chr(10)next iend sub3设学生成绩的平均分已在mark(1)至mark(10)中,学生姓名在name(1)至name(10)中。private sub command1_click()dim i%,j%,t%,s$for i=1 to 9for j=i+1 to 10if mark(i)<mark(j) then t=mark(i):mark(i)=mark(j):mark(j)=ts=name(i):n
12、ame(i)=name(j):name(j)=snext jnext ifor i=1 to 10print name(i),mark(i)next iend sub第八章 习题参考答案一、选择题:110: dcbbdddbcb二、填空题1a ubound(b) n=n-12key=a(i) index=-1三、编程题1子过程sub p1(x as single, esp as single)dim p!,s!,f!,i%p=1:s=1:i=1:f=xdop=p*is=s+f/ploop until abs(f/p)<esp print send sub子函数function p2(x
13、as single, esp as single) as singledim p!,s!,f!,i%p=1:s=1:i=1:f=xdop=p*is=s+f/ploop until abs(f/p)<esp p2=send function2swap2能实现数据交换。因为地址传递方式形参和实参有共同的地址,那么形参的变化,会引起实参的变化(即形参将值回传给实参),故可实现两数交换。3function lf( byval x as single) as singlelf=x*x*xend functionsub command1_click()dim i%for i=1 to 20print
14、 i, lf(i)next iend sub4function weekday(byval x as integer) as stringselect case xcase 0weekday=”星期日”case 1weekday=”星期一”case 2weekday=”星期二”case 3weekday=”星期三”case 4weekday=”星期四”case 5weekday=”星期五”case 6weekday=”星期六”end selectend function5function rand30(byval x asinteger) as integerrandomizerand30=i
15、nt(rnd*x+1)end functionsub command1_click()for i=1 to 30print rand30(100)next iend sub6function f1(byval x assingle, byval y assingle) as integerif x>y thenf1=xelsef1=yend ifend function7function gdbh(byval x%) as stringdim i%for i = 3 to x - 3 step 2if isp(i) and isp(x - i) thengdbh = i & &q
16、uot;+" & (x - i) & "=" & xexit functionend ifnextend functionfunction isp(y%) as booleani = 2: k = int(y / 2)do while i <= kif y mod i = 0 then exit doi = i + 1loopif i > k thenisp = trueelseisp = falseend ifend functionprivate sub form_click()for i = 6 to 40 step 2p
17、rint gdbh(i)next iend sub8function isqo(byval x as integer) as stringif x mod 2 =0 thenisqo=”偶数”elseisqo=”奇数”end ifend function9function f1(byval x as integer) as booleanif x mod 17 =0 and x mod 37 =0thenf1=trueelsef1=falseend ifend functionprivate sub form_click()for i = 1000 to 2000if f1(i) thenpr
18、int iend ifnext iend sub10sub f1(a() as integer, byval l1 as integer, byval l2 asinteger)dim l%, u%, x%, i%l = lbound(a): u = ubound(a)if l1 > u or l2 > u thenprint "位置输入错误!"exit subend ifif l1 > l2 thenx = a(l1)for i = l1 to l2 + 1 step -1a(i) = a(i - 1)next ia(l2) = xelseif l2 &
19、gt; l1 thenx = a(l1)for i = l1 to l2 - 1a(i) = a(i + 1)next ia(l2) = xend ifend sub第九章 习题参考答案一、选择题:13: add二、填空题1下拉式 弹出式 2popupmenu 3visible enabled 4-三、编程题(略)第十章 习题参考答案一、选择题:13: dbd二、填空题1load 2窗体模块 标准模块 类模块 3doevents三、编程题1(略)2function f(byval x&,byval y&) as integerdim t&,r&if x<y
20、 then t="x:x=y:y=t r= x mod ydo while r<>0x=yy=rr= x mod yloopf=yend functionprivate sub command1_click()text3 = val(text1) / f(val(text1), val(text2)text4 = val(text2) / f(val(text1), val(text2)end sub第十一章 习题参考答案一、选择题:13: dda二、填空题6 2ab a 三、编程题1private sub form_mousemove(button as integer
21、, shift as integer, xas single, y as single)text1 = x: text2 = yend sub2dim startx, starty as integer 在通用中申明private sub form_mousedown(button as integer, shift as integer, x assingle, y as single)if button = 2 thenstartx = x: starty = yend ifend subprivate sub form_mousemove(button as integer, shift
22、 as integer, x assingle, y as single)if button = 1 thenpset (x, y), rgb(0, 0, 0)end ifend subprivate sub form_mouseup(button as integer, shift as integer, x assingle, y as single)if button = 2 thendim r%, c%dim endx, endy as integerendx = x: endy = yc = rgb(0, 0, 0)r = sqr(endx - startx) 2 + (endy -
23、 starty) 2)form1.circle (startx, starty), r, cend ifend sub第十二章 习题参考答案一、选择题:18: bbabbcca9i h f c l g e b a j k d二、填空题1drive 2path print dir1.path3path 4hidden system5顺序文件 随机文件 二进制文件6freefile7close #18open “c:samplesreadme.txt” for output as #39open “c:autoexec.bat” for intput as #410open “c:samplesx
24、scj.dat” for random as #3 len=5411open “smtext1.txt” for binary as #112for input eof(1)13keyascii end(或者end end end end) text1.text三、编程题1在标准模块中定义type stuid as string * 12name as string * 8z1 as string * 12z2 as string * 12sex as string * 2jc as booleanscool as string * 20sx as integeryw as integeryy
25、 as integerwl as integerzf as integerend typedim p as stu 在通用中定义private sub cmdappend_click()p.id = t = text2p.z1 = text3p.z2 = text4p.scool = text5if option1.value = true then p.sex = "男"if option2.value = true then p.sex = "女"if check1.value = 1 then p.jc = true else
26、p.jc = falsep.sx = val(text6) : p.yw = val(text7)p.yy = val(text8) : p.wl = val(text9)p.zf = val(text10)put #1, , pend subprivate sub cmddisplay_click()get #1, val(txtrecord_no), ptext1 = p.id : text2 = text3 = p.z1 : text4 = p.z2text5 = p.scoolif p.sex = "男" then option1.value = tru
27、e else option2.value = trueif p.jc = true then check1.value = 1 else check1.value = 0text6 = p.sx : text7 = p.ywtext8 = p.yy : text9 = p.wltext10 = p.zfend subprivate sub command3_click()text1 = "" : text2 = ""text3 = "" : text4 = ""text5 = "" : text
28、6 = ""text7 = "" : text8 = ""text9 = "" : text10 = ""end subprivate sub form_load()open app.path & "stu.dat" for random as #1 len = len(p)end subprivate sub form_unload(cancel as integer)close #1end subprivate sub text10_gotfocus()text10 = val(text6) + val(text7) + val(text8) + val(text9)end sub2.3.4.private type booksid as string * 10name as string * 8sex as string * 2math as integereng as integerele as integerend type成绩输入private sub command1_click()dim b as booksopen
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 福建体育职业技术学院《治安学》2025-2026学年期末试卷
- 集美工业职业学院《语法学》2025-2026学年期末试卷
- 厦门华天涉外职业技术学院《现代金融统计》2025-2026学年期末试卷
- 骨外科考研试题及答案
- 徐州医科大学《电子测量原理》2025-2026学年期末试卷
- 乳制品充灌工10S执行考核试卷含答案
- 社会经济咨询公司年度工作总结报告
- 金箔制作工风险评估知识考核试卷含答案
- 起重工班组协作考核试卷含答案
- 炭素煅烧操作工QC管理强化考核试卷含答案
- 北京市2025北京市体育科学研究所招聘7人笔试历年参考题库典型考点附带答案详解
- 县教育局2026年中小学生安全教育周活动总结
- 清明细雨-在追思中看清自己的方向-2025-2026学年高三下学期主题班会
- 2026年中考英语专题复习:完形填空 专项练习题汇编(含答案 解析)
- 2026年上海数据交易所“金准估”估值模型与大宗标准定价法应用
- 教科版三年级下册科学实验报告(20 篇)
- 2026年成都辅警招聘笔试题库含答案
- 2026年教师资格认证教育心理学试题集及答案解析
- 2025年10月自考00292市政学试题及答案
- GB/T 24810.1-2026起重机限制器和指示器第1部分:通则
- 肾癌的转移-图文
评论
0/150
提交评论