當前位置:才華齋>計算機>計算機二級>

計算機等級考試二級VB考前練習

計算機二級 閱讀(7.41K)

為了使廣大考生在備戰計算機等級考試時,更快的掌握相應知識點,下面是小編搜尋整理的計算機等級考試二級VB考前練習,供參考練習,預祝考生們考出自己理想的成績!

計算機等級考試二級VB考前練習

1. 下面程式是從鍵盤上輸入一個字串,把該字串中的大寫字母轉換成小寫字母,輸出到檔案中,然後從該檔案中讀出字串並顯示出來。請完善下面的程式:

Private Form_Click( )

Dim Str1 As String * 50 , Str2 As String , FileNo As Integer

FileNo = 【63】

Open “d:” For 【64】As FileNo

Str1 = InputBox ( “請輸入一個字串:” )

Str1 = Lcase ( Str1 )

Seek #FileNo , 1

Put #FileNo, , Str1

【65】#FileNo, 1

Str2 = Input (【66】, #FileNo )

Print Str2

End Sub

【63】(A)Free (B)File (C)FreeFile (D)FileFree

【64】(A)Input (B)Output (C)Random (D)Binary

【65】(A)Loc (B)Lof (C)Eof (D)Seek

【66】(A)Len ( Str1 ) (B)Len ( Str2 ) (C)StrLen ( Str1 ) (D)StrLen (Str2)

2. 以下程式的功能是:把當前目錄下的順序檔案的內容讀入記憶體,並在文字框Text1中顯示出來。請填空。

Private Sub Command1_Click()

Dim inData As String

= ""

Open "" 【14】 As #1

Do While 【15】

Input #1, inData

= & inData

Loop

Close #1

End Sub

3. 在窗體上畫一個文字框(其Name屬性為Text1),然後編寫如下事件過程:

Private Sub Form_Load( )

= “ ”

ocus

For i = 1 to 10

Sum = Sum + i

Next i

= Sum

End Sub

程式執行後,輸出結果為( 【67】 )

(A)在文字框Text1中輸出55 (B)在文字框Text1中輸出0

(C)在文字框Text1中輸出不定值 (D)出錯

4. 在窗體上畫一個文字框和一個列表框,然後編寫如下兩個事件過程:

Private Sub Form_Load( )

tem “123 ”

tem “456 ”

tem “369”

tem “789 ”

= “ ”

End Sub

Private Sub List1_DblClick( )

a =

Print a +

End Sub

程式執行後,在文字框中輸入“248”,然後雙擊列表框中的`“369”,則輸出結果( 【68】 )

(A)617 (B)248369 (C)369248 (D)0

5. 在窗體上畫兩個滾動條,名稱分別為Hscroll1 、Hscroll2;六個標籤,名稱分別為 Label1、Label2、Label3、Label4、Label5、Label6,其中標籤Label 4~ Label6分別顯示“A”、“B”、“A*B”等文字資訊,標籤Label1、Label2分別顯示其右側的滾動條的數值,Label3 顯示A*B的計算結果。如圖所示。當移動滾動框時,在相應的標籤中顯示滾動條的值。當單擊命令按鈕"計算"時,對標籤Label1、Label2中顯示的兩個值求積,並將結果顯示在Label3中。以下不能實現上述功能的事件過程是

(A)Private Sub Command1_Click()

ion = Str(Val(ion )*Val( ion))

End Sub

(B)Private Sub Command1_Click()

ion = e * e

End Sub

(C)Private Sub Command1_Click()

ion = HScroll1 * HScroll2

End Sub

(D)Private Sub Command1_Click()

ion = HScroll1. Text *

End Sub

6. 閱讀下面程式:

Public Sub xy ( a As Integer , b As Integer )

Dim t As Integer

Do

t = a Mod b

a = b : b = t

Loop While t

Print a

End Sub

用Call xy (16 , 40 )呼叫此通用過程後,輸出結果為( 【69】 )

(A)4 (B)8 (C)16 (D)32

7. 在窗體上畫一個名稱為Command1的命令按鈕,然後編寫如下事件過程:

Private Sub Command1_Click()

For n = 1 To 20

If n Mod 3 <> 0 Then m = m + n 3

Next n

Print n

End Sub

程式執行後,如果單擊命令按鈕,則窗體上顯示的內容是

(A)15 (B)18 (C)21 (D)24

8. 以下語句的輸出結果是( 【70】 )

a = “BeiJing”

b = “ShangHai”

Print a;b

以下結果中,“ □ ”表示空格:

(A)BeiJing□ShangHai (B)BeiJingShangHai

(C)BeiJingShangHai□ (D)BeiJing□ShangHai□

9. 下面程式共執行了( 【71】 )次迴圈。

Dim Intsum As Integer , i As Integer , j As Integer

i = 1 : j = 1

Do

Do

Intsum = Intsum + j

j = j + 2

Print j;

Loop Until j > 3

i = i + 1

Loop Until i > 11

Print Intsum

(A)10 (B)11 (C)12 (D)13

10. 下列程式執行後,變數x的值為( 【72】 )

Dim a , b , c , d , x As Single

a = 200 : b = 100 : c = 500

If b > a Then

d = a : a = b : b = d

End If

If b > c Then

x = b

ElseIf a > c Then

x = c

Else

x = a

End If

Print x

(A)0 (B)100 (C)200 (D)500