




版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、vb課后習題答案第一章 習題參考答案一、 填空題1、對象 事件驅(qū)動2、編譯運行模式 解釋運行模式二、 簡答題1、 簡述vb的特點。答:可視化的程序設計方法面向?qū)ο蟮某绦蛟O計思想事件驅(qū)動的編程機制結構化的程序設計語言高度的可擴充性強大的數(shù)據(jù)庫訪問能力支持動態(tài)數(shù)據(jù)交換支持對象鏈接與嵌入2、簡述vb的安裝過程。答:向光驅(qū)中放入vb安裝光盤;計算機將運行自動安裝程序,若沒有,執(zhí)行vb目錄下的setup.exe;根據(jù)提示逐一回答問題,并點擊“下一步”;點擊“完成”;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 字符型、字節(jié)型、整型、長整型、單精度型、雙精度型、貨幣型、邏輯型、日期型、對象型、變體型。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)數(shù)值型常量(單精度) 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單價、數(shù)量、折扣和應付款對應的文本框的名稱分別為: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統(tǒng)計按鈕名為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子函數(shù)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能實現(xiàn)數(shù)據(jù)交換。因為地址傳遞方式形參和實參有共同的地址,那么形參的變化,會引起實參的變化(即形參將值回傳給實參),故可實現(xiàn)兩數(shù)交換。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=”偶數(shù)”elseisqo=”奇數(shù)”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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 信息技術必修一《數(shù)據(jù)與計算》第二章第二節(jié)《程序設計語言基本知識》教學設計
- 定西師范高等??茖W?!渡茖W基礎二:細胞生物學》2023-2024學年第二學期期末試卷
- 沈陽職業(yè)技術學院《中醫(yī)藥文化與養(yǎng)生》2023-2024學年第二學期期末試卷
- 駐馬店職業(yè)技術學院《寫意畫》2023-2024學年第二學期期末試卷
- 阜陽幼兒師范高等專科學?!峨娮泳€路CAD技術B》2023-2024學年第二學期期末試卷
- Unit 3 Amazing animals PartA (教學設計)-2024-2025學年人教PEP版(2024)英語三年級上冊
- 鹽城師范學院《現(xiàn)代材料分析技術》2023-2024學年第二學期期末試卷
- 廣東云浮中醫(yī)藥職業(yè)學院《民俗學與民間文學》2023-2024學年第二學期期末試卷
- 鋼軌購銷合同范本
- 山西大同大學《三維機械CAD實驗》2023-2024學年第二學期期末試卷
- DZ∕T 0332-2020 碳酸鹽巖油氣藏縫洞體雕刻法資源儲量估算規(guī)范(正式版)
- 社會學(高校社會學入門課程)全套教學課件
- 心血管介入護士進修匯報
- 施工組織設計內(nèi)部審批表
- 《企業(yè)的可持續(xù)發(fā)展》課件
- 零至三歲兒童及老年人中醫(yī)保健指導專業(yè)知識講座培訓課件
- DB12-T 1305-2024 公路瀝青路面泡沫瀝青冷再生技術規(guī)范
- 范文語文評課稿15篇
- 2024年山東省春季高考技能考試汽車專業(yè)試題庫-中(多選題匯總)
- 2016-2023年德州科技職業(yè)學院高職單招(英語/數(shù)學/語文)筆試歷年參考題庫含答案解析
- 《人文科學概論》課件
評論
0/150
提交評論