vb程序設(shè)計(jì)》期末復(fù)習(xí)題及答案_第1頁(yè)
vb程序設(shè)計(jì)》期末復(fù)習(xí)題及答案_第2頁(yè)
vb程序設(shè)計(jì)》期末復(fù)習(xí)題及答案_第3頁(yè)
vb程序設(shè)計(jì)》期末復(fù)習(xí)題及答案_第4頁(yè)
vb程序設(shè)計(jì)》期末復(fù)習(xí)題及答案_第5頁(yè)
已閱讀5頁(yè),還剩42頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、vb 程序設(shè)計(jì)期末復(fù)習(xí)題及答案一、填空題1創(chuàng)建一個(gè)vb應(yīng)用程序三個(gè)主要的步驟是_、_和_。2當(dāng)程序運(yùn)行時(shí),要求窗體中的文本框呈現(xiàn)空白,則在設(shè)計(jì)時(shí),應(yīng)當(dāng)在此文本框的_窗口中,把此文本框的 _屬性設(shè)置成空白。3label 和 textbox 控件用來(lái)顯示和輸入文本,如果僅需要讓?xiě)?yīng)用程序在窗體中顯示文本信息,可使用_控件;若允許用戶輸入文本,則應(yīng)使用_控件。4窗體的常用方法有_、_、_和_。5要想在代碼中給名為txtshow的文本框賦予文本:good work ,應(yīng)當(dāng)編寫(xiě)的語(yǔ)句是_ 。6若命令按鈕的名稱為cmdopen ,程序要求單擊該命令按鈕時(shí),打開(kāi)一個(gè)窗口frm1 ,請(qǐng)對(duì)以下事件過(guò)程填空。pri

2、vate sub cmdopen_ _ _ end sub 7visual basic 6種類型的表達(dá)式是_、_ 、_、_、_、_。visual basic根據(jù)表達(dá)式的_來(lái)確定表達(dá)式的類型。8表達(dá)式93 7 mod 2 2 的值是 _。9已知 a=3,b=4,c=5,表達(dá)式ab and not ca or cb and ca and not b=1.7 and w=62.5 b、t=62.5 c、t1.7 and w=1.7 or w a + b or b - 1 c - 1 and c + a a xor b c - 2 end sub 7#12/31/1999# - #12/20/1999

3、#的運(yùn)算結(jié)果是 #12/11/1999# 8可以在窗體的通用部分聲明靜態(tài)變量。9使用聲明語(yǔ)句建立一個(gè)變量后,visual basic會(huì)自動(dòng)對(duì)數(shù)值類型的變量賦初值0,變長(zhǎng)的字符串被初始化為一個(gè)零長(zhǎng)度的字符串 ,定長(zhǎng)字符串用空格填充,variant變量被初始化為 empty ,布爾型的變量被初始化為false 。10事件過(guò)程通常由事件驅(qū)動(dòng)執(zhí)行,而sub 過(guò)程通過(guò)過(guò)程調(diào)用執(zhí)行。11將焦點(diǎn)主動(dòng)設(shè)置到指定的控件或窗體上應(yīng)采用setfocus 方法。12當(dāng)圖像控件(image)的 stretch屬性為 true 時(shí), image 控件能自動(dòng)調(diào)整自己的尺寸與顯示的圖片匹配。四、讀程序題,寫(xiě)出程序運(yùn)行結(jié)果。1

4、private sub form_click() for i = 1 to 9 for j = 1 to 30 - 3 * i print ; next j for k = 1 to i print k; next k for k = i - 1 to 1 step -1 print k; next k print next i end sub 2option explicit private sub command1_click() static s as integer dim i as integer s = 1 for i = 1 to 5 s = s * i next i print

5、 s end sub 3 for x = 5 to 1 step -1 for y = 1 to 6 - x print tab(y + 5); *; next y print next x 4 private sub form_activate() print aa & bb,-5 * 6,not 2 = 3 print aa & bb; -5 * 6; not 2 = 3 print print 30+60, print 30 + 60 ?30+60; 30 + 60 end sub 5x=1 do while x=10 if x mod 7 =0 then y = x +

6、 6 else z = x end if x = x + 2 loop print x,y,z 五、編程題1設(shè)計(jì)一個(gè)計(jì)算程序。該程序用戶界面如圖所示,由四個(gè)文本框:文本框1(text1 )、文本框2(text2 )、文本框 3( text3 )、文本框4(text4 ),和三個(gè)按鈕:命令按鈕1(command1 )、命令按鈕2(command2 )、命令按鈕3(command4 )組成。程序運(yùn)行后,用戶單擊清除按鈕,則清除文本框中顯示的內(nèi)容。單擊計(jì)算按鈕,如果成績(jī)填寫(xiě)不完全,則給出提示信息,否則計(jì)算三科平均成績(jī)。單擊退出按鈕則退出。2設(shè)計(jì)程序。要求:從文本框text1 中接收輸入的數(shù)據(jù),當(dāng)單擊

7、確定按鈕(command1 )時(shí),如果該數(shù)據(jù)滿足條件:除以3 余 2,除以 5 余 3,除以 7 余 4,則輸出;否則將焦點(diǎn)定位在文本框text1 中,選中其中的文本。3設(shè)計(jì)一個(gè)歡迎程序。該程序用戶界面如圖所示。要求程序運(yùn)行后,用戶選中粗體復(fù)選框時(shí),標(biāo)簽(label1 )中的文字(歡迎您?。┑淖煮w變成粗體,用戶選中斜體復(fù)選框時(shí),標(biāo)簽的字體變成斜體。若取消選中,則恢復(fù)原字體。單擊結(jié)束,則退出。4任意輸入3 個(gè)數(shù),求大小排第二的那個(gè)數(shù),寫(xiě)出程序代碼。vb 期末復(fù)習(xí)參考答案一、填空題1創(chuàng)建應(yīng)用程序界面設(shè)置屬性編寫(xiě)代碼2屬性、 text 3label textbox 4 load 方法 show 方法

8、 hide 方法 unload 方法5txtshow.text=good work 6click()、frm1.show 7算術(shù)表達(dá)式字符串表達(dá)式關(guān)系表達(dá)式布爾表達(dá)式日期表達(dá)式對(duì)象表達(dá)式運(yùn)算符8 1 9true false 10 12 11sin(x) 2 + sqr(x 2 - y 2) / (2 * x) 12dim a(1 to 5,-2 to 6) as string 13單擊雙擊裝載多響應(yīng)某個(gè)事件后所執(zhí)行的程序代碼 cmd1 click 14完成某種特定的功能對(duì)象名 . 方法名 form1.show 15autosize stretch 16filecopy c:,d: 二、單項(xiàng)選擇

9、題1b 2 c 3 c 4 d 5 d 6 b 7 b 8d 9 d 10 c 11 d 12 a 13 c 三、指出下列句中的錯(cuò)誤,修改或者說(shuō)明原因。1int.sum 不正確。變量名中不能包括小數(shù)點(diǎn)。2變量名的長(zhǎng)度最長(zhǎng)可達(dá)255 個(gè)字符。3 3.6 , 4 因?yàn)?a 不是整型變量。4不正確。程序不可以改變字符的長(zhǎng)度,這是vb規(guī)定。5不完全正確。variant是一種特殊的數(shù)據(jù)類型,除了定長(zhǎng)字符串?dāng)?shù)據(jù)及用戶定義類型外,可以包含任何種類型的數(shù)據(jù),這是vb規(guī)定。6false 。邏輯表達(dá)式計(jì)算結(jié)果。7不正確。兩個(gè)日期型數(shù)據(jù)相減,其結(jié)果是一個(gè)數(shù)值型數(shù)據(jù)。8不正確。靜態(tài)變量為局部變量,只能在過(guò)程中聲明。9

10、正確。10正確。11正確。12不正確。該屬性設(shè)為ture 時(shí), image 控件不能自動(dòng)調(diào)整自己的尺寸與顯示的圖片匹配,而可以使圖片自動(dòng)擴(kuò)展以適應(yīng)控件的尺寸。四、讀程序題,寫(xiě)出程序運(yùn)行結(jié)果。1程序運(yùn)行后,單擊窗體,輸出結(jié)果為:1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 4 5 4 3 2 1 1 2 3 4 5 6 5 4 3 2 1 1 2 3 4 5 6 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 2程序運(yùn)行后,單擊按鈕command1 ,輸出結(jié)果

11、為:120。3. * * * * * 4. aabb -30 false aabb-30 false 30+60 90 30+60 90 5. 11 13 9 五、編程題1private sub command1_click() text1.text = text2.text = text3.text = text4.text = end sub private sub command2_click() a = trim(text1.text) b = trim(text2.text) c = trim(text3.text) if a = or b = or c = then msgbox

12、成績(jī)填寫(xiě)不完全!, vbcritical else text4.text = (val(a) + val(b) + val(c) / 3 end if end sub private sub command3_click() unload me end sub 2private sub command1_click() x = val(text1.text) if x mod 3 = 2 and x mod 5 = 3 and x mod 7 = 4 then print x else text1.setfocus text1.selstart = 0 text1.sellength = le

13、n(text1.text) end if end sub 3private sub check1_click() if check1.value = 1 then else end if end sub private sub check2_click() if check2.value = 1 then else end if end sub private sub command1_click() unload me end sub 4a = val(inputbox(輸入第一個(gè)數(shù):) b = val(inputbox(輸入第二個(gè)數(shù):) c = val(inputbox(輸入第三個(gè)數(shù):)

14、if a b then t = a: a = b: b = t if a c then t = a: a = c: c = t if b c then t = b: b = c: c = t msgbox ( 求大小排第二的數(shù)是: & b) vb期末考試試題 a 卷一、填空題1、vb程序設(shè)計(jì)的主要特點(diǎn)是(1)和(2)。2、在 vb中,最主要的兩種對(duì)象是( 3)和(4)。3、工程是構(gòu)成應(yīng)用程序文件的(5)。4、方法是vb提供的一種(6),用來(lái)完成一定的操作。5、浮點(diǎn)類型數(shù)據(jù)包括單精度型和_(7)_數(shù)據(jù)。6、事件是窗體或控件對(duì)象識(shí)別的_(8)_。7、可用窗體的 _(9)_ 方法在窗體中顯示

15、文字。8、 復(fù)選框控件value 屬性指示復(fù)選框處于_(10)_或禁止?fàn)顟B(tài) (暗淡的 ) 中的某一種。9、在 vb中,修改窗體的(11)和(12)屬性值,可改變窗體的大小。10、雙擊工具箱中的控件圖標(biāo),可在窗體的(13)出現(xiàn)一個(gè)尺寸為缺省值的控件。11、在 msgbox函數(shù)中,如果缺省title參數(shù),則使用(14)作為消息框的標(biāo)題。12、設(shè) x34.58 ,語(yǔ)句 print format(x,“000.0 ”) 的輸出結(jié)果是(15) 。13、在 vb 中,數(shù)值型變量的初值為( 16) , varant 型變量的初值為(17),布爾型變量的初值為(18)。14、設(shè)置窗體的(19)屬性,可在窗體上

16、顯示圖片。15、程序運(yùn)行工程中,清除mp圖片框中的圖片應(yīng)使用語(yǔ)句(20) 。二、選擇題1、菜單控件只包括一個(gè)事件,即(1),當(dāng)用鼠標(biāo)單擊或鍵盤(pán)選中后按“回車”鍵時(shí)觸發(fā)該事件,除分隔條以外的所有菜單控件都能識(shí)別該事件。a、gotfocus b、load c、click d、keydown 2、滾動(dòng)條控件(如圖所示 ) 的 max屬性所設(shè)置的是(2)。a、滾動(dòng)框處于最右位置時(shí),一個(gè)滾動(dòng)條位置的value 屬性最大設(shè)置值b、 單擊滾動(dòng)條和滾動(dòng)箭頭之間的區(qū)域時(shí),滾動(dòng)條中滾動(dòng)塊的最大移動(dòng)量c、單擊滾動(dòng)條的箭頭區(qū)域時(shí),滾動(dòng)條中滾動(dòng)塊的最大移動(dòng)量d、滾動(dòng)條控件無(wú)該屬性3、sql 語(yǔ)句 select * fo

17、rm student 中的 * 表示(3)。a、所有記錄 b、所有字段 c、所有表 d 、都不對(duì)4、以下選項(xiàng)中,不屬于標(biāo)簽的屬性是( 4)。a、enabled b、caption c、default d、font 5、要求改命令按鈕顯示的文本,應(yīng)當(dāng)在屬性窗口中改變的屬性是(5)。 a、caption b、name c、text d、label 6、設(shè)置一個(gè)單選按鈕(optionbutton)所代表選項(xiàng)的選中狀態(tài),應(yīng)當(dāng)在屬性窗口中改變的屬性是(6)。 a、caption b、 name c、text d、value 7、允許在菜單項(xiàng)的左邊設(shè)置打勾標(biāo)記,下面哪種論述是正確的?(7)。 a、在標(biāo)題項(xiàng)

18、中輸入&,然后打勾 b、在索引項(xiàng)中打勾 c 、在有效項(xiàng)中打勾 d、在復(fù)選項(xiàng)中打勾8、當(dāng)執(zhí)行以下過(guò)程時(shí),在窗體上將顯示(8)。private sub command1_click( ) print vb; print hello! ; print vb end sub a、 vbhello!vb b、 vb hello!vb c、 vb d、 vb hello! vb hello! vb 9、語(yǔ)句 print the answer is:;20/4-2的結(jié)果為(9)。a、the answer is 20/4-2 b、the answer is 3 c、the answer is 20/4

19、-2 d、非法語(yǔ)句10、下列哪個(gè)控件是容器控件( 10)。 a、image b、picture c、combobox d、filelistbox 11、若要將窗體從內(nèi)存中卸載出去,其實(shí)現(xiàn)的方法是(11)。a.show b.hide c.load d.unload 12、以下選項(xiàng)中,不是 visual basic控件的是(12)。 a. 窗體 b.定時(shí)器 c.單選框 d. 命令按鈕13、雙擊窗體中的對(duì)象后,visual basic將顯示的窗口是(13)。 a.代碼窗口 b 工具箱 c 項(xiàng)目(工程)窗口 d屬性窗口14、可決定窗體的左上角是否有控制菜單的屬性是(14)。a.controlbox b

20、.minbutton c.maxbutton d.borderstyle 15、設(shè)有如下語(yǔ)句: strlinputbox ( 輸人 , ,練習(xí) )從鍵盤(pán)上輸人字符“示例”后,strl的值是(15)。 a“輸入” b“” c“練習(xí)” d“示例”16、窗體 form1的 name屬性是 frm1,它的單擊事件過(guò)程名是(16)。 a. form1_click b.form_click c. frm1_click d. me_click 17 、窗體的 hide 屬性的含義是( 17)。 a. 隱藏 b.展現(xiàn) c.裝入 d.卸載18、若要設(shè)置定時(shí)器控件的定時(shí)時(shí)間,需設(shè)置的屬性是(18)。aenable

21、d bvalue cinterval d text 19、能夠改變復(fù)選框中背景顏色的屬性是(19)。 avalue b fontcolor cbackcolor dfont 20、窗體能響應(yīng)的事件是(20)。 aactiveform bload cdrive dchange 三、判斷題 ( 判斷下列正確與否,正確的打,錯(cuò)誤的打。) 1、三種方式的組合框都允許用戶輸入哪些不在列表框中的選項(xiàng)。2、圖象框中的stretch屬性為 true 時(shí),其作用是圖形自動(dòng)調(diào)整大小以適應(yīng)圖象控件。3、在菜單編輯器中使用“索引”時(shí),可有一組菜單項(xiàng)具有相同的“名字”。4、通過(guò)改變屬性窗口中的name屬性,來(lái)改變窗體的

22、標(biāo)題。5、創(chuàng)建 vb應(yīng)用程序的三個(gè)主要步驟是:(1) 創(chuàng)建應(yīng)用程序界面(2) 設(shè)置控件 (3) 編寫(xiě)代碼。6、變量是指在程序運(yùn)行過(guò)程中其值可以改變的那些量,而值不能改變的是常量。7、已知 pmsgbox(“howareyou? ,vbyesno+vbquestion,“ hello!”) ,變量 p是 integer數(shù)據(jù)類型。8、工程文件的擴(kuò)展名是 .vbg 。9、vb允許設(shè)計(jì)和使用用戶自己設(shè)計(jì)的控件。10、optionbutton控件沒(méi)有 dblcliek事件。11、同一條記錄中的各數(shù)據(jù)具有相同的類型。12、使用 data 控件可以直接顯示數(shù)據(jù)庫(kù)中的數(shù)據(jù)。13、imagelist 是一個(gè)圖像

23、容器控件,可用作工具欄的圖像庫(kù)。14、當(dāng)用戶單擊工具欄按鈕時(shí),將觸發(fā)工具欄按鈕的buttonclick事件。15、在 vb的工程資源管理器中,如果從工程中移除已經(jīng)保存過(guò)的文件,該文件仍然被物理刪除(真正刪除)。16、如果列表框的listconut的屬性為10,則列表框最后一項(xiàng)的listindex值為 10。17、要是某個(gè)命令按鈕不起作用,應(yīng)將該按鈕的enabeld 屬性設(shè)置為false 。18、使用數(shù)組定義語(yǔ)句:dim d$(10),則數(shù)組d中各元素的值為空。19、如果在一行中輸入多條語(yǔ)句,各語(yǔ)句之間用使用;分隔。20、在代碼窗口中輸入某行代碼并按回車鍵之后,如果代碼變成紅色,說(shuō)明該行代碼有語(yǔ)

24、法錯(cuò)誤。四、讀程序題,寫(xiě)出程序運(yùn)行結(jié)果 1、 private sub form_click() static sum as integer i = 1 do while i=10 sum = sum + i i = i + 1 loop print sum end sub 運(yùn)行程序,第一次單擊窗體:第二次單擊窗體:2、 private sub form_click() print *; tab(6); 2, tab(15); 5 print for i = 15 to 16 print i; for j = 2 to 6 step 3 print tab(3 * j); j * i; next

25、 j print next i end sub 程序運(yùn)行結(jié)果:五、編程題(一)窗體中有圖片框(picture1)和計(jì)時(shí)器 (timer1) 兩個(gè)控件,運(yùn)行程序時(shí),將圖片加載到圖片框中,然后圖片框以每2 秒鐘一次的速度向窗體的右下腳移動(dòng),每次向左、向右移動(dòng)100twip (20 分之一像素)。請(qǐng)?zhí)羁眨?private sub form_load( ) (1)=loadpicture(“ c: ball.ico”)(2) .interval=200 end sub private sub timer1_timer( ) static x , y as integer x=x+100 y=y+100

26、 picture1.move (3) end sub (二)有一個(gè)單擊按鈕過(guò)程,其作用是產(chǎn)生50 個(gè) 60100 的隨機(jī)數(shù),統(tǒng)計(jì)其中被6 整除余 2的個(gè)數(shù),并將這些數(shù)輸出。請(qǐng)?zhí)羁眨?private sub command1_click() dim x as integer, n% dim counter as integer (1) timer for n=1 to 50 x=rnd()* (2) if (3) =2 then print x counter= (4) (5) next n print counter end sub vb 程序設(shè)計(jì)與應(yīng)用參考答案一、填空題1 2 3 4 5 答

27、案可視化設(shè)計(jì)事件驅(qū)動(dòng)編程窗體( form )控件集合題號(hào)6 7 8 9 10 答案特殊子程序雙精度動(dòng)作print 選中題號(hào)11 12 13 14 15 答案高度(height )寬度 (width) 中央工程 1 34.6 題號(hào)16 17 18 19 20 答案0 空f(shuō)alse picture cls 二、選擇題1 2 3 4 5 答案c a b c a 題號(hào)6 7 8 9 10 答案d d a b b 題號(hào)11 12 13 14 15 答案d a a a d 題號(hào)16 17 18 19 20 答案c a c c b 三、判斷題1 2 3 4 5 6 7 8 9 10 答案11 12 13 1

28、4 15 16 17 18 19 20 答案四、程序閱讀題:(一)(10 分) 1 、 55 2、 110 (二)、(10 分)* 2 5 15 30 75 16 32 80 五、編程題(20 分)(一) 1、 picture1.picture 2 、 timer1 3、 x ,y (二) 1 、 randomize 2、 rnd()*41+60 3、 x mod 6 4、 counter 1 5 end if 一、單項(xiàng)選擇題(共10 分)1在代碼中引用一個(gè)控件時(shí),應(yīng)使用控件的(b)屬性。 acaption b name c text d index 2設(shè)變量x = 4 ,y = -1 ,a

29、= 7 ,b = -8, 下面表達(dá)式(a)的值為 “ 假” 。 ax+a 0 and y y d x+y a+b and not (y b = c and a = d的值為 false 。三、將下列數(shù)學(xué)表達(dá)式轉(zhuǎn)換為vb 表達(dá)式。( 6 分)1a2+2ab+b2 : a2+2*a*b+b2 28exln10 :8*exp(x)*log(10) 32sin(450)cos(450) :2*sin(3.1416/4)*cos(3.1416/4) 6在 vb 中,用戶定義常量使用 const 語(yǔ)句,聲明變量使用 dim 語(yǔ)句。1在 vb 6.0 中,擴(kuò)展名為 .vbp 的文件稱為 a 。a) 工程文件

30、b) 窗體文件c) 類模塊文件d) 標(biāo)準(zhǔn)模塊文件2在 vb 6.0 集成開(kāi)發(fā)環(huán)境的設(shè)計(jì)模式下,用鼠標(biāo)雙擊窗體上的某個(gè)對(duì)象后,打開(kāi)的窗口是 a 。a) 代碼窗口b) 窗體設(shè)計(jì)窗口c) 屬性窗口d) 工程資源管理器窗口3設(shè)有變量定義語(yǔ)句dim a%,則變量a 的數(shù)據(jù)類型是 a 。a) 整型b) 單精度類型c) 雙精度類型d) 字符串類型4下列表達(dá)式中,值為false 的是 d 。a) ababc b) abc = ucase(abc) c) abcdabc d) mid(abcd,3,1)=left(abcd,3) 5函數(shù) instr(abcdef, cd)的值是 b 。a) 2 b) 3 c)

31、true d) cdef 6下列程序運(yùn)行后,單擊窗體,輸出結(jié)果是 c 。private sub form_click() dim a as integer, b as integer a = 3 b = 5 print a + b; a & b end sub a) 8 8 b) 35 35 c) 8 35 d) 35 8 7下列程序運(yùn)行后,單擊窗體,輸出結(jié)果是 b 。private sub form_click() a = 3: b = 7 a = a + b : b = a b : a = a - b print a; b end sub a) 4 3 b) 7 3 c) 3 7

32、d) 10 7 8下面程序段所表示的數(shù)學(xué)關(guān)系式是 c 。if (a b) then if d = c then x = 1 else x = 2 end if a) )(2)c(1dcbadbax且且b) )(2)c(1dcbadbax且且c) )(2)c(1badbax且d) )(2)c(1dcdbax且9下列程序運(yùn)行后,單擊窗體,輸出結(jié)果是 c 。private sub form_click() s = 0: k = 1 do s = s + k: k = k + 1 loop until k = 5 print s end sub a) 15 b) 10 c) 1 d) 0 10下列程序

33、段的輸出結(jié)果是 b 。for k = 4 to 2 step -2 m = k next k print m; k; a) 2 2 b) 2 0 c) 2 1 d) 0 0 11用下面的語(yǔ)句定義數(shù)組,則數(shù)組中的元素個(gè)數(shù)是 d 個(gè)。option base 1 dim a(-1 to 2,5) as integer a) 5 b) 10 c) 15 d) 20 12下面程序段的輸出結(jié)果是 c 。dim a(4) as integer, s as integer for k = 1 to 4 a(k) = 2 * k next k for k = 1 to 4 step 2 s = s + a(k)

34、 print s; next k a) 8 b) 20 c) 2 8 d) 2 6 12 20 13設(shè)有如下的用戶自定義類型private type stu name as string * 10 age as integer end type 則以下正確引用該類型成員的代碼是 b 。a) s=zhang b) dim s as stu = zhang c) dim s as type stu = zhang d) dim s as type = zhang 14用“ b ”關(guān)鍵字聲明的變量稱為全局變量。a) private b) pub

35、lic c) dim d) static 15在窗體上放置一個(gè)文本框,程序運(yùn)行后,在文本框中輸入abc,但顯示的卻是* ,可能的原因是該文本框的 d 屬性值已經(jīng)被設(shè)置為* 。a) font b) text c) name d) passwordchar16在 vb 6.0 中, print是對(duì)象的 b 。a) 屬性b) 方法c) 事件d) 名稱17在 vb 6.0 中,要判斷復(fù)選框是否為選中狀態(tài),使用的屬性是 d 。a) caption b) checked c) selected d) value18設(shè)列表框list1中共有3 個(gè)列表項(xiàng),如右圖所示。則下列語(yǔ)句中,能夠刪除最后一個(gè)列表項(xiàng)的是

36、a 。a) list1.removeitem 2 b) list1.removeitem 項(xiàng)目 c c) list1.removeitem list1. listcount d) list1.removeitem list1. listindex 19組合框分為下拉式組合框、簡(jiǎn)單組合框和下拉式列表框,在“屬性”窗口中這三種類型是由 a 屬性設(shè)置的。a) styleb) fillstyle c) backstyle d) borderstyle 20用戶單擊滾動(dòng)條的空白處(滑塊與兩端滾動(dòng)箭頭之間的區(qū)域)時(shí),value 屬性所增加或減少的值,是由 d 屬性決定的。a) min b) max c)

37、smallchange d) largechange 21將圖片文件“b.jpg ”作為背景圖片,裝入當(dāng)前窗體,正確的語(yǔ)句是 d 。a) me.picture=b.jpg b) me.picture= loadpicture(b.jpg) c) me.picture=b.jpg d) me.picture= loadpicture(b.jpg) 22要將兩個(gè)單選按鈕放置在同一個(gè)框架內(nèi),使它們成為一組,正確的操作是 a 。a) 先放置一個(gè)框架,然后在框架中放置兩個(gè)單選按鈕b) 先放置兩個(gè)單選按鈕,再放置一個(gè)框架,放置框架時(shí)覆蓋在單選按鈕上c) 先放置兩個(gè)單選按鈕,再放置一個(gè)框架,然后將兩個(gè)單選按

38、鈕拖動(dòng)到框架內(nèi)d) 以上三種方法都正確23計(jì)時(shí)器控件能夠響應(yīng)的事件是 d 。a) load b) click c) change d) timer 24要使命令按鈕處于無(wú)效狀態(tài),可以設(shè)置按鈕的 b 屬性值為false 。a) caption b) enabled c) style d) visible 25如果在一個(gè)工程中有多個(gè)窗體和模塊,則vb默認(rèn)的啟動(dòng)對(duì)象是 c 。a) 第一個(gè)標(biāo)準(zhǔn)模塊b) 最后一個(gè)被添加的窗體c) 設(shè)計(jì)時(shí)的第一個(gè)窗體d) 最后一個(gè)被添加的標(biāo)準(zhǔn)模塊26在窗體上放置一個(gè)圖像框,名稱為image1。程序運(yùn)行時(shí),要保持圖像框大小不變,使框中的圖片能夠自動(dòng)適應(yīng)圖像框的大小,可以執(zhí)行

39、語(yǔ)句 b 。a) image1.autosize=true b) image1.stretch=true c) image1.autosize=false d) image1.stretch=false 27使用“菜單編輯器”建立菜單項(xiàng)之間的分隔線時(shí),在菜單項(xiàng)的“標(biāo)題”中輸入的符號(hào)是 a 。a) 減號(hào) - b) 下劃線 _ c) & d) # 28要將窗體form1從內(nèi)存中卸載,正確的語(yǔ)句是 d 。a) form1.show b) load form1 c) form1.hide d) unload form1 29在窗體上單擊時(shí),會(huì)觸發(fā)鼠標(biāo)事件mousedown ,其事件過(guò)程的一般格

40、式如下:private sub form_mousedown(button as integer, shift as integer, x as single, y as single) end sub 此時(shí),如果單擊的是鼠標(biāo)右鍵,則button 參數(shù)的值是 b 。a) 1 b) 2 c) 3 d) 4 30獲取文件的長(zhǎng)度(字節(jié)數(shù)),可以使用的函數(shù)是 b 。a) len( ) b) lof( ) c) eof( ) d) log( ) 1數(shù)學(xué)表達(dá)式y(tǒng)xy3改寫(xiě)為 vb表達(dá)式,形式是【1】。答案 sqr(3*y) /(x+y)2在 vb 6.0 中, inputbox函數(shù)返回值的數(shù)據(jù)類型是【 2

41、】。答案:字符串類型或string3語(yǔ)句 print tab(5);abc 的功能是【3】。答案:從第5 列開(kāi)始輸出字符串“abc ”4下面程序段的功能是:在文本框text1 中輸入一個(gè)數(shù)值x,如果滿足5x10,那么輸出“yes”,否則輸出“no”。請(qǐng)?zhí)羁?。x =val(text1.text) 答案 5 x and x 10 if 【 4】 then print yes else print no 5設(shè) a=1,b=2,c=3 ,語(yǔ)句 print a b or b c and c 3 m = m + 2 case 1 to 4 m = m + 3 end select next k print

42、 m end sub 3在窗體上放置一個(gè)文本框,名稱為text1 。下列程序運(yùn)行后,單擊窗體,text1中顯示的內(nèi)容是【3】。答案: adeprivate sub form_click() text1.text = s = abd12re for k = 1 to len(s) ch = mid(s, k, 1) if ch = a and ch p then p = x(k) s = s + p end if next k print p; s end sub 5下列程序運(yùn)行后,單擊窗體,輸出結(jié)果是【5】。答案: 1 5 1private sub form_click() dim a(1 t

43、o 3, 1 to 3) for i = 1 to 3 for k = 1 to 3 if k = 1 or i = k then a(i, k) = 1 else a(i, k) = i + k end if next k next i print a(1, 1); a(2, 3); a(3, 3) end sub 6在窗體上放置一個(gè)命令按鈕,名稱為command2 ,并編寫(xiě)如下代碼。private sub command2_click() dim m as integer, n as integer, g as integer m = 18: n = 12: g = 0 call sub1

44、(m, n, g) print m; n; g end sub public sub sub1(byval a as integer, byval b as integer, c as integer) if a b then t = a: a = b: b = t do while b 0 r = a mod b a = b b = r loop c = a end sub 程序運(yùn)行后,單擊命令按鈕,則輸出結(jié)果是【6】。答案: 18 12 67在窗體上放置一個(gè)命令按鈕,名稱為command3 ,并編寫(xiě)如下代碼。private sub command3_click() dim k as int

45、eger k = 1 print fun1(k); print fun1(k); print fun1(k); end sub function fun1(a as integer) as integer static c as integer dim b as integer a = a + 2: b = b + 2: c = c + 2 fun1 = a + b + c end function 程序運(yùn)行后,單擊命令按鈕,則輸出結(jié)果是【7】。答案: 7 11 158在窗體上放置一個(gè)文本框,其名稱為text1 ,并編寫(xiě)如下代碼。dim s as string private sub text

46、1_keypress(keyascii as integer) s = s + chr(keyascii) print s; end sub 程序運(yùn)行后,在文本框中輸入abc,則窗體上輸出的內(nèi)容是【8】。 答案: aababc1在窗體上放置一個(gè)計(jì)時(shí)器和一個(gè)標(biāo)簽,計(jì)時(shí)器名稱為timer1 ,標(biāo)簽名稱為label1 。下列程序的功能是:(1)在窗體加載事件中設(shè)置計(jì)時(shí)器每秒鐘能夠觸發(fā)5 次 timer 事件;(2)每觸發(fā)一次timer 事件能夠?qū)?biāo)簽上的字號(hào)加大2,當(dāng)字號(hào)超過(guò)當(dāng)前窗體的寬度時(shí),將字號(hào)恢復(fù)為8。程序中有一處錯(cuò)誤,請(qǐng)更正。說(shuō)明錯(cuò)誤時(shí)可以使用每條語(yǔ)句前的編號(hào)。(1) private sub

47、 form_load() (2) timer1.interval = 5 答案: 200(3) timer1.enabled = true (4) end sub (5) private sub timer1_timer() (6) label1.fontsize = label1.fontsize + 2 (7) if label1.fontsize me.width then (8) label1.fontsize = 8 (9) end if (10) end sub 2下列程序的功能是計(jì)算1+3+5+99 的和 s。程序中有一處錯(cuò)誤。請(qǐng)更正。說(shuō)明錯(cuò)誤時(shí)可以使用每條語(yǔ)句前的編號(hào)。(1)

48、s = 0 (2) k = 1 (3) do while k = 1e-4 e = e + p n = n + 1 p = 【 6】答案: p / nloop print e的近似值 =; e end sub 3在下圖所示的窗體上放置的主要控件及其主要的屬性設(shè)置如下:控件類型控件名稱屬性屬性值標(biāo)簽label1 caption 示例文字命令按鈕command1 caption 設(shè)置單選按鈕option1 caption 宋體option2 caption 隸書(shū)下列程序的功能是單擊命令按鈕后,根據(jù)單選按鈕的選中狀態(tài),將標(biāo)簽中的“示例文字”設(shè)置為相應(yīng)的字體。請(qǐng)?zhí)羁胀晟瞥绦?。private sub c

49、ommand1_click() dim fn as string fn:存放選中的字體 if 【 7】 then 答案: option1.value = true fn = 宋體 else fn = 隸書(shū) end if 【8】 = fn 答案: label1.fontnameend sub 4下列程序中用戶自定義函數(shù)ave 的功能是求一維數(shù)組中所有元素的平均值,并返回。單擊窗體時(shí),能夠輸入數(shù)組a 的 10 個(gè)元素,并調(diào)用函數(shù)ave,求數(shù)組a 中所有元素的平均值,并顯示輸出。請(qǐng)?zhí)羁胀晟瞥绦?。option base 1 private sub form_click() dim a(10) as s

50、ingle for i = 1 to 10 a(i) = val(inputbox(輸入一個(gè)數(shù)值) next i print 平均值 =; 【9】 調(diào)用函數(shù) ave 答案: ave(a)end sub public function ave(b() as single) as single dim s as single dim n as integer n = ubound(b) for k = 1 to n s = s + b(k) next k 【10】答案: ave = s / nend function vb期末范圍題總匯1 求隨機(jī) 10 個(gè)整數(shù)的最大值、最小值、平均值以及和;dim

51、 a(1 to 10) private sub command1_click() randomize picture1.print 產(chǎn)生的隨機(jī)數(shù)為: for i = 1 to 10 a(i) = int(rnd * 99 + 1) picture1.print a(i); next i picture1.print end sub private sub command2_click() dim max, min, ave max = a(1) min = a(1) ave = 0.1 * a(1) for i = 2 to 10 if a(i) max then max = a(i) if

52、a(i) n1 then 為了求最小公倍數(shù),增加m,n 變量m = m1: n = n1 else m = n1: n = m1 end if do r = m mod n if r = 0 then exit do m = n n = r loop print n1; ,; m1; 的最大公約數(shù)為 ; n print 最小公倍數(shù) =, m1 * n1 / n end sub 7. 求逆序數(shù)(感覺(jué)題目類型太多)8. 級(jí)數(shù)有限項(xiàng)求和問(wèn)題(題目類型太多)9. 求質(zhì)因子問(wèn)題private sub command1_click() dim n as integer, i as integer n =

53、val(inputbox(請(qǐng)輸入 2 的整數(shù) :) i = 2 do if n mod i = 0 then print i; n = n i else i = i 1 end if loop while n 1 end sub 10. 字符統(tǒng)計(jì)option base1 option explicit private sub command1_click() dim i as integer,a(26) as integer,n as integer dim s as string*1,strl as string strl=text1 n=len(strl) for i=1 to n s=m

54、id(strl,i,1) if ucase(s)= ”a” and ucase(s)= ”z” then a(asc(ucase(s)-64)+1 end if next i for i=1 to 26 list1.additem chr(64+i) & “: ” & a(i) netx i end sub private sub command_click() end end sub 第二大題1. 判定素?cái)?shù)過(guò)程function isprime(num as long) as boolean if num = b, a, b) x存入最大值y = iif(a a(j) then

55、 t = a(j - 1) a(j - 1) = a(j) a(j) = t end if next next end sub 4 順序查找過(guò)程private sub command1_click() dim i, j, t, a(1 to 10) randomize print 原數(shù)組 : for i = 1 to 10 a(i) = int(rnd * 10) print a( & i & ) = & a(i) & space(2), if i mod 2 = 0 then print end if next i print for i = 1 to 9 f

56、or j = i + 1 to 10 if a(j) max then max = a(i) if a(i) n1 then 為了求最小公倍數(shù),增加m,n 變量m = m1: n = n1 else m = n1: n = m1 end if do r = m mod n if r = 0 then exit do m = n n = r loop print n1; ,; m1; 的最大公約數(shù)為 ; n print 最小公倍數(shù) =, m1 * n1 / n end sub 7. 求逆序數(shù)(感覺(jué)題目類型太多)8. 級(jí)數(shù)有限項(xiàng)求和問(wèn)題(題目類型太多)9. 求質(zhì)因子問(wèn)題private sub co

57、mmand1_click() dim n as integer, i as integer n = val(inputbox(請(qǐng)輸入 2 的整數(shù) :) i = 2 do if n mod i = 0 then print i; n = n i else i = i 1 end if loop while n 1 end sub 10. 字符統(tǒng)計(jì)option base1 option explicit private sub command1_click() dim i as integer,a(26) as integer,n as integer dim s as string*1,strl

58、 as string strl=text1 n=len(strl) for i=1 to n s=mid(strl,i,1) if ucase(s)= ”a” and ucase(s)= ”z” then a(asc(ucase(s)-64)+1 end if next i for i=1 to 26 list1.additem chr(64+i) & “: ” & a(i) netx i end sub private sub command_click() end end sub 第二大題1. 判定素?cái)?shù)過(guò)程function isprime(num as long) as b

59、oolean if num = b, a, b) x存入最大值y = iif(a a(j) then t = a(j - 1) a(j - 1) = a(j) a(j) = t end if next next end sub 4 順序查找過(guò)程private sub command1_click() dim i, j, t, a(1 to 10) randomize print 原數(shù)組 : for i = 1 to 10 a(i) = rnd * 10 print a( & i & ) = & a(i) & space(2), if i mod 2 = 0 th

60、en print next i print for i = 1 to 9 for j = i + 1 to 10 if a(j) max then max = a(i) if a(i) n1 then 為了求最小公倍數(shù),增加m,n 變量m = m1: n = n1 else m = n1: n = m1 end if do r = m mod n if r = 0 then exit do m = n n = r loop print n1; ,; m1; 的最大公約數(shù)為 ; n print 最小公倍數(shù) =, m1 * n1 / n end sub 7. 求逆序數(shù)(感覺(jué)題目類型太多)8. 級(jí)數(shù)有限項(xiàng)求和問(wèn)題(題目類型太多)9. 求質(zhì)因子問(wèn)題private sub command1_click() dim n as integer, i as integer n = val(in

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論