<pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

          <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

          <p id="bbfd9"></p>

          <p id="bbfd9"><cite id="bbfd9"></cite></p>

            <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

            <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
            <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
            試題

            計算機二級VB考試習題及答案

            時間:2025-03-22 14:27:19 試題 我要投稿

            2017年計算機二級VB考試習題及答案

              計算機等級考試越來越受到同學們的重視,下面是小編為大家整理的2017年計算機二級VB考試習題及答案,歡迎學習!

            2017年計算機二級VB考試習題及答案

              習題一

              1.以下程序是求最大公約數和最小公倍數的程序,在【】處填寫合適的關系運算符。

              Private Sub Form_Click( )

              Dim m1, n1, m, n, r As Integer

              n1 = InputBox("輸入自然數n", "輸入數")

              m1 = InputBox("輸入自然數m", "輸入數")

              n = n1

              m = m1

              If m

              t = m: m = n: n = t

              End If

              r = m Mod n

              Do While r 【<>】 0

              m = n

              n = r

              r = m Mod n

              Loop

              Print "最大公約數=", n

              Print "最小公倍數= ", m1 * n1 / n

              End Sub

              2.下面是求100以內素數的程序。

              Private Sub Command1_Click( )

              Dim i As Integer, m As Integer, tag As Boolean

              For m = 2 To 100

              tag = True

              For i = 2 To m - 1

              If m Mod 【i】 = 0 Then tag = False

              Next i

              If tag Then Print m

              Next m

              End Sub

              3.下面是求100以內素數的程序,下面說法正確的是(A)(單)

              Private Sub Command1_Click( )

              Dim i As Integer, m As Integer, tag As Boolean

              For m = 2 To 100

              tag = True

              For i = 2 To m - 1

              If m Mod i = 0 Then tag = False

              Next i

              If tag=true Then Print m

              Next m

              End Sub

              A.tag為true時,表示m是素數

              B.tag為false時,表示m是素數

              C.語句m Mod i = 0,說明m是素數

              D.以上說法都不正確

              4.百元買百雞問題: 假定小雞每只5角,公雞每只2元,母雞每只3元。現在有100元錢要求買100只雞,以下程序列出了所有可能的購雞方案。

              Private Sub Command2_Click( )

              Dim x%, y%, z%

              For x = 0 To 33

              For y = 0 To 50

              If 3 * x + 2 * y + 0.5 * (100 - x - y) = 100 Then

              Picture2.Print x, y, 【100-x-y,10-y-x】

              End If

              Next y

              Next x

              End Sub

              5.百元買百雞問題: 假定小雞每只5角,公雞每只2元,母雞每只3元。現在有100元錢要求買100只雞,以下程序列出了所有可能的購雞方案。

              Private Sub Command1_Click( )

              Dim x%, y%, z%

              For x = 0 To 33

              For y = 0 To 50

              For z = 0 To 100

              If 3 * x + 2 * y + 0.5 * z = 100 And 【x+y+z=100】 Then

              Picture1.Print x, y, z

              End If

              Next z

              Next y

              Next x

              End Sub

              6.隨機產生10個100~200之間的數,求它們的最大值程序如下:

              Private Sub Command1_Click( )

              Max = 100

              For i = 1 To 10

              x = Int(Rnd * 101 + 100)

              Print x;

              If x > Max Then 【】

              Next i

              Print

              Print "最大值="; Max

              End Sub

              在此程序中,其中【】處應該填寫的是(C)(單)

              A.Max = 100

              B.Max =200

              C.Max = x

              D.Max = 0

              7.隨機產生10個100~200之間的數,求它們的最大值程序如下:

              Private Sub Command1_Click( )

              Max = 100

              For i = 1 To 10

              x = int【RND*101+100或100+RND*101或RND()*101+100或100+RND()*101】

              Print x;

              If x > Max Then Max=x

              Next i

              Print

              Print "最大值="; Max

              End Sub

              8.隨機產生10個100~200之間的數,求它們的最大值程序如下:

              Private Sub Command1_Click( )

              Max = 100

              For I = 1 To 10

              x =Int(Rnd * 101 + 100)

              Print x;

              If 【】 Then Max=x

              Next I

              Print

              Print "最大值="; Max

              End Sub

              在【】處應該填寫的是:(A)(單)

              A.x > Max

              B.x

              C.x = Max

              D.以上都不正確

              9.以下是求1~100之間5或7的倍數的和,如下程序段:

              Sum = 0

              For i = 1 To 100

              If i Mod 5 = 0 Or i Mod 7 = 0 Then

              【】

              End If

              Next i

              Print Sum

              其中【】處書寫正確的是(B)(單)

              A.Sum = i

              B.Sum = Sum + i

              C.Sum = Sum + 5+7

              D.以上都不正確

              10.以下是求1~100的5或7的倍數的和程序段:

              Sum = 0

              For i = 1 To 100

              If i Mod 5 = 0 Or i 【mod】 7=0 Then

              Sum = Sum + i

              End If

              Next i

              Print Sum

              習題二

              1.在窗體上畫一個名稱為Text1的文本框,一個名稱為Command1的命令按鈕,然后編寫如下事件過程和通用過程:

              Private Sub Command1_Click( )

              n = Val(Text1.Text)

              If n\2 = n/2 Then

              f = f1(n)

              Else

              f = f2(n)

              End If

              Print f; n

              End Sub

              Public Function f1(ByRef x)

              x=x*x

              f1=x+x

              End Function

              Public Function f2(ByVal x)

              x=x*x

              f2=x+x+x

              End Function

              程序運行后,在文本框中輸入3,然后單擊命令按鈕,窗體上顯示的是(D)(單)

              A.72 36

              B.108 36

              C.72 6

              D.27 3

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

              Private Sub Command1_Click( )

              c = "1234"

              For i = 1 To 4

              c1 = Trim(Str( ))

              Print c1

              Next i

              End Sub

              程序運行后,單擊命令按鈕,要求在窗體上顯示如下內容

              1

              12

              123

              1234

              則在下劃線處應填入的內容為(B)(單)

              A.Right(c1,i)

              B.Left(c1,i)

              C.Mid(c1,i,1)

              D.Mid(c1,i,i)

              3.在窗體上畫一個名稱為Command1的命令按鈕和一個名稱為Text1的文本框,然后編寫如下事件過程:

              Private Sub Command1_Click( )

              n = Val(Text1.Text)

              For i = 2 To n

              For j = 2 To sqr(i)

              If i Mod j = 0 Then Exit For

              Next j

              If j >Sqr(i) Then Print i

              Next i

              End Sub

              該事件過程的功能是(C)(單)

              A.輸出n以內的奇數

              B.輸出n以內的偶數

              C.輸出n以內的素數

              D.輸出n以內能被j整除的數

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

              Private Function f(m As Integer)

              If m Mod 2 = 0 Then

              f = m

              Else

              f = 1

              End If

              End Function

              Private Sub Command1_Click( )

              Dim i As Integer

              s = 0

              For i = 1 To 5

              s = s + f(i)

              Next

              Print s

              End Sub

              程序運行后,單擊命令按鈕,在窗體上顯示的是(C)(單)

              A.11

              B.10

              C.9

              D.8

              5.在窗體上畫一個名稱為Text1的文本框和一個名稱為Command1的命令按鈕,然后編寫如下事件過程:

              Private Sub Command1_Click( )

              Dim array1(10, 10) As Integer

              Dim i As Integer, j As Integer

              For i = 1 To 3

              For j = 2 To 4

              array1(i, j) = i + j

              Next j

              Next i

              Text1.Text = array1(2, 3) + array1(3, 4)

              End Sub

              程序運行后,單擊命令按鈕,在文本框中顯示的值是(D)(單)

              A.15

              B.14

              C.13

              D.12

              6.Visual Basic應用程序中標準模塊文件的擴展名是【BAS或.BAS】(注意不要寫點)。

              7.在菜單編輯器中建立一個菜單,其主菜單項的名稱為mnuEdit,Visible屬性為False,程序運行后,如果用鼠標右鍵單擊窗體,則彈出與mnuEdit相應的菜單。

              Private Sub Form_ 【mousedown】 (Button As Integer, Shift As Integer, X As Single, Y As Single)

              If Button=2 Then

              popupmenu mnuEdit

              End If

              End Sub

              8.在菜單編輯器中建立一個菜單,其主菜單項的名稱為mnuEdit,Visible屬性為False,程序運行后,如果用鼠標右鍵單擊窗體,則彈出與mnuEdit相應的菜單。以下是實現上述功能的程序,請填空。

              Private Sub Form mousedown (Button As Integer, Shift As Integer, X As Single, Y As Single)

              If Button=2 Then

              【popupmenu】 mnuEdit

              End If

              9.為了使計時器控件Timer1每隔0.5秒觸發一次Timer事件,應將Timer1控件的【Interval】屬性設置為500。

              10.為了使計時器控件Timer1每隔0.5秒觸發一次Timer事件,應將Timer1控件的Interval屬性設置為【500】。

            【計算機二級VB考試習題及答案】相關文章:

            計算機二級考試《VB》基礎習題及答案07-22

            2017計算機二級《VB》考試備考習題及答案06-29

            計算機二級考試VB練習題及答案05-27

            2016計算機二級考試VB練習題及答案05-24

            2017計算機二級《VB》考試鞏固習題及答案05-08

            計算機二級考試VB強化練習題及答案07-26

            計算機二級VB考試練習題及答案07-17

            2017年計算機二級考試VB習題及答案06-07

            2017計算機二級考試VB練習題及答案03-29

                    <pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

                    <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

                    <p id="bbfd9"></p>

                    <p id="bbfd9"><cite id="bbfd9"></cite></p>

                      <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

                      <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
                      <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
                      飘沙影院