一、選擇題
(1)—(35)題每題2分,共70分。
下列各題a)、b)、c)、d)四個先項中,只有一個選擇是正確的,請將正確選項塗寫在答題卡相應位置上,答在試卷上不得分。
(1) 下列不能打開屬性視窗的操作是 。
a) 執行“視圖”選單中的“屬性視窗”命令
b) 按f4鍵
c) 按ctrl+t
d) 單擊工具列上的“屬性視窗”按鈕 。
(2) 下列可以打開立即視窗的操作是 。
a) ctrl+d b) ctrl+e c) ctrl+f d) ctrl+g
(3) inputbox函式反回值的類型為 。
a) 數值b) 字元串
c) 變體d) 數值或字元串(視輸入的數據而定)
(4) 可以同時刪除字元串前導和尾部空白的函式是 。
a) ltrim b) rtrim c) trim d) mid
(5) 表達式4+5 6 * 7 / 8 mod 9 的值是
a) 4 b) 5 c) 6 d) 7
(6) 如果在立即視窗中執行以下操作:
a=8 <cr>(<cr>是回車鍵,下同)
b=9 <cr>print a>b <cr>
則輸出結果是 。
a) -1 b) 0 c) false d) true
(7) 以下語句的輸出結果是 。
print format $(32548.5,“000,000.00”)
a) 32548.5 b) 32,548.5 c) 032,548.50 d) 32,548.50
(8) 執行以下程式段後,變數c$=“visual basic programing”b$=“quick”
c$=b$ & ucase(mid$(a$,7,6)) & right $ (a$,11)
a) visual basic programing
b) quick basic programing
c) quick basic programing
d) quick basic programing
(9) 為了在按下回車鍵時執行某個命令按鈕的事件過程,需要把該命令按鈕的一個屬性設定為true,這個屬性是。
a) value b) default c) cancel d) enabled
(10)為了把焦點移到某個指定的控制項,所使用的方法是
a) setfocus b) visible c) refresh d) getfocus
(11)設a=6,則執行 x=iif(a>5,-1,0)後,x 的值為 。
a) 5 b) 6 c) 0 d) -1
(12)執行下面的程式段後,x 的值為。
x=5for i=1 to 20 step 2
x=x+i5
next i
a) 21 b) 22 c) 23 d) 24
(13)在窗體上畫一個命令按鈕,然後編寫如下事件過程:
private sub command1_click()for i=1 to 4
x=4
for j =1 to 3
x=3
or k=1 to 2
x=x+6
next k
next j
next i
print x
end sub
程式運行後,單擊命令按鈕,輸出結果是 。
a) 7 b) 15 c) 157 d) 538
(14)在窗體上畫一個命令按鈕,然後編寫如下事件過程:prevate sub command1_click()x=0
do until x=-1
a = inputbox(“請輸入a的值”)a = val(a)
b = inputbox(“請輸入b的值”)b = val(b)
x = inputbox(“請輸入x的值”)x = val(x)
a = a+b+x
loop
print a
end sub
程式運行後,單擊命令按鈕,依次在輸入對話框中輸入5、4、3、2、1、-1,則輸出結果為。
a) 2b) 3 c) 14 d) 15
(15)在窗體(name屬性為form1)上畫兩個文本框(其name屬性分別為text1和text2)和一個命令按鈕(name 屬性為command1),然後編寫如下兩個事件過程:
private sub command1_click()a=text1.text+text2.text
print a
end sub
private sub formm_load()text1 text=""
text2 text=""
end sub
程式運行後,在第一個文本框(text1)和第二個文本框(text2)中分別輸入123和321,然後單擊命令按鈕,則輸出結果為。
a) 444 b) 321123 c) 123321 d) 132231
(16)閱讀下面的程式段:for i=1 to 3for j=1 to i
for k=j to 3
a=a+1
next k
next j
next i
執行上面的三重循環後,a 的值為 。
a) 3b) 9 c) 14 d) 21
(17)在窗體上畫一個文本框(其中name屬性為text1),然後編寫如下事件過程:private sub form_load()ttext1.text="">
text1.setfocus
for i=1 to 10
sum=sum+i
next i
text1.text=sum
end sub
上述程式的運行結果是 。
a) 在文本框text1中輸出55b) 在文本框text1中輸出0c) 出錯d) 在文本框text1中輸出不定值
(18)在窗體上畫兩個文本框(其name 屬性分別為text1和text2)和一個命令按鈕(其name屬性為command1),然後編寫如下事件過程:private sub command1_click()x=0
do while x<50
x=(x+2)*(x+3)
n=n+1
loop
text1.text=str(n)
text2.text=str(x)
end sub
程式運行後,單擊命令按鈕,在兩個文本框中顯示的值分別為
a) 1和0 b) 2和72 c) 3和50 d) 4和168
(19)用下面語句定義的數組的元素個數是。
dim a (- 3 to 5 ) as integer
a) 6b) 7 c) 8 d) 9
(20)以下程式的輸出結果是option base 1private sub command1_click()
dim a(10),p(3) as integer
k=5
for i=1 to 10
a(i)=i
next i
for i=1 to 3
p(i)=a(i*i)
next i
for i=1 to 3
k=k+p(i)*2
next i
print k
end sub
a) 33 b) 28 c) 35 d) 37
(21)在窗體上面畫一個命令按鈕,然後編寫如下事件過程:option base 1private sub commandl_click()
dim a
a = array(1,2,3,4)
j = 1
for i = 4 to step -1
s = s + a(i)*j
j =j*10
next i
print s
end sub
運行上面的程式,單擊命令按鈕,其輸出結果是 。
a) 4321b) 12 c) 34 d) 1234
(22)在窗體上面一個命令按鈕(其name屬性為commandl),然後編寫如下代碼:option base 1private sub commandl_click( )
dim a(4,4)
for i =1 to 4
for j =1 to 4
a(i,j) = (i-1)*3+j
next j
next i
for i =3 to 4
for j =3 to 4
print a(j,i);
next j
print
next i
end sub
程式運行後,單擊命令按鈕,其輸出結果為 。
a) 6 9 b) 7 10 c) 8 11 d) 9
127 10 8 11 9 12 10 13
(23)假定有如下的sub過程:sub s(x as single,y as single)t = xx =t/y
y =t mod y
end sub
在窗體上畫一個命令按鈕,然後編寫如下事件過程:private sub commandl_click ( )dim a as single
dim b as single
a =5
b =4
s a,b
print a,b
end sub
程式運行後,單擊命令按鈕,輸出結果為 。
a) 5 4 b) 1 1 c) 1.25 4 d) 1.25 1
(24)閱讀程式:function f(a as integer)b = 0
static c
b = b+1
c = c+1
f = a+b+c
end function
private sub commandl_click ()dim a as integer
a =2
for i =1 to 3
print f(a)
next i
end sub
運行上面的程式,單擊命令按鈕,輸出結果為 。
a) 4b) 4 c) 4 d) 4
4 5 67
4 6 89
(25)閱讀程式:sub subp(b() as integer)for i =1 to 4
b(i)=2*i
next i
end sub
private sub commandl_click()dim a(1 to 4)as integer
a (1)=5
a (2)=6
a (3)=7
a (4)=8
subp a ()
for i =1 to 4
print a(i)
next i
end sub
運行上面的程式,單擊命令按鈕,輸出結果為 。
a)2b)5 c)10d)出錯
4 6 12
6 7 14
8 8 16
(26)下列不能打開選單編輯器的操作是 。
a)按ctrl+e
b)單擊工具列中的“選單編輯器”按鈕
c)執行“工具”選單中的“選單編輯器”命令
d)按shift + alt + m
(27)假定有一個選單項,名為menuitem,為了在運行時使該選單項失效(變灰),應使用的語句為 。a) menuitem. enabled=false
b) menuitem. enabled=true
c) menuitem. visible=true
d) menultem. visible=false
(28)在程式運行期間,如果拖動滾動條上的滾動塊,則觸發的滾動條事件是 。
a) move b) change c) scroll d) getfocus
(29)假定窗體上有一個標籤,名為labell,為了使該標籤透明並且沒有框線,則正確的屬性設定為 。
a) label1. backstyle=0 label1.borderstyle=0
b) label1.backstyle=1 label1.borderstyle=1
c) label1.backstyle=true label1.borderstyle=true
d) label1.backstyle=false label1.borderstyle=false
(30)在窗體上畫一個列表框和一個文本框,然後編寫如下兩個事件過程:private sub form_load ()list1.additem"357"
list1.additem"246"
list1.additem"123"
listl.additem"456"
text1.text=""
end sub
private sub list1_ dblclick ( )a =list1.text
print a+text1.text
end sub
程式運行後,在文本框中輸入“789”(見圖1),然後雙擊列表框中的"456",則輸出結果為 。a) 1245 b) 456789 c) 789456 d) 0
(31)為了暫時關閉計時器,應把該計時器的某個屬性設定為false ,這個屬性是。
a) visible b) timer c) enabled d) interval
(32)為了把一個記錄型變數的內容寫入檔案中指定的位置,所使用的語句的格式為 。
a)get檔案號,記錄號,變數名
b)get檔案號,變數名,記錄號
c)put檔案號,變數名,記錄號
d)put檔案號,記錄號,變數名
(33)對窗體編寫如下事件過程:private sub form _mousedown(button as integer, _shift as integer, x as single y as single)
if button =2 then
print "aaaaa"
end if
end sub
private sub form _ mouseup(button as integer, _shift as integer, x as single, y as single)
print "bbbbb"
end sub
程式運行後,如果單擊滑鼠右鍵,則輸出結果為。
a) aaaaa b) bbbbb c) aaaaa d) bbbbbbbbbb aaaaa
(34)為了在運行時能顯示窗體左上角的控制框(系統選單),必須。
a) 把窗體的contro1box 屬性設定為fale,其他屬性任意
b) 把窗體的controlbox 屬性設定為true,並且把boder style屬性設定為1-5
c) 把窗體的controlbox 屬性設定為false,同時把boderstyle屬性調協為非0值
d) 把窗體的controlbox 屬性設定為true,同時把boderstyle屬性設定為0值
(35)對窗體編寫如下代碼:option base 1private sub form_keypress(keyascii as integer)
a = array(237,126,87,48,498)
m1 = a(1)
m2 = 1
if keyascii = 13 then
for i =2 to 5
if a(i)>ml then
m1 =a(j)
m2 =i
end if
next i
end if
print m1
print m2
end sub
程式運行後,按回車鍵,輸出結果為
a) 48 b) 237 c) 498 d) 498
4 1 5 4
二、填空題(每空2分,共30分)
請將每空的正確答案寫在答題卡[1]—[15]序號的橫線上,答在試卷上不得分。
(1)設有如下的visual basic表達式:5 * x^2 – 3 * x – 2 * sin(a)/3它相當於代數式【1】 。
(2)執行下面的程式段後,s的值為 【2】 。
s = 5for i = 2.6 to 4.9 step 0.6
s = s+1
next i
(3)表達式fix(-32.68)+int(-23.02)的值為【3】 。
(4)為了在運行時把圖形檔案picfile. jpg裝入圖片框picture1,所使用的語句為【4】 。
(5)在窗體上畫一個命令按鈕,然後編寫如下事件過程:
private sub command1_click()a = inputbox("請輸入一個整數")
b = inputbox("請輸入一個整數")
print a + b
end sub
程式運行後,單擊命令按鈕,在輸入對話框中分別輸入321和456,輸出結果為 【5】。
(6) 執行下面的程式段後,b的值為【6】。
a=300b=20
a=a+b
b=a-b
a=a-b
(7) 以下程式段的輸出結果是【7】 。
num=0while num<=2
num=num+1
print num
wend
(8) 在窗體畫一個命令按鈕,然後編寫如下事件過程:private sub command1_click()dim a(1 to 10)
dim p(1 to 3)
k=5
for i=1 to 10
a(i)=i
next i
for i=1 to 3
p(i)=a(i*i)
next i
for i=1 to 3
k=k+p(i)*2
next i
print k
end sub
程式運行後,單擊命令按鈕,輸出結果是【8】 。
(9) 下面的程式用“冒泡”法將數組a中的10個整數按升序排列,請在【9】、【10】、【11】處將程式補充完整。
option base 1private sub command1_click()
dim a
a=array(678,45,324,528,439,387,87,875,273,823)
for i=【9】for j=【10】if a(i)【11】 a(j) thena1=a(i)
a(i)=a(j)
a(j)=a1
end if
next j
next i
for i=1 to 10
print a(i)
next i
end sub
(10) 在窗體畫一個命令按鈕,然後編寫如下過程:function fun(byval num as long)as longdim k as long
k=1
num=abs(num)
do while num
k=k*(num mod 10)
num=num10
loop
fun=k
end function
private sub command1_click()dim n as long
dim r as long
n=inputbox("請輸入一個數")n=clng(n)
r=fun(n)
print r
end sub
程式運行後,單擊命令按鈕,在輸入對話框中輸入234,輸出結果為【12】 。
(11) 如果要將某個選單項設計為分隔線,則該選單項的標題應設定為【13】。
(12) 假定建立了一個工程,該工程包括兩個窗體,其名稱(name 屬性)分別為form1和form2,啟動窗體為form1。在form1畫一個命令按鈕command1,程式運行後,要求當單擊該命令按鈕時,form1窗體消失,顯示窗體form2,請在【14】和【15】處將程式補充完整。
private sub command1_click()【14】 form1form2. 【15】end sub