亚洲国产福利在线一二三观看_精品国产伦一区二区三区欲臀_国产a∨视频精品视频护士_精品八戒人妻少妇av

江蘇省高校計算機等級考試命題研究院 江蘇省高校計算機等級考試輔導
2005秋江蘇省等級考試筆試卷(2)

第二部分 VB程序設計

一、 選擇題

21.以下所列的8個控件中,具有Caption屬性的有         個。

CheckBox(復選框)、ComboBox(組合框)、HscrollBar(水平滾動條)、DirListBox(文件夾列表框)、Image(圖像框)、Frame(框架)、Label(標簽)、Line(線條)

A5              B4               C3             D2

22.執(zhí)行下面語句后,Len函數(shù)值最大的是          。

Dim IA As Integer, B As Single, S As String *5, Ch As String

IA=32767  : B=23.5  : S=”A”  :Ch=”abcd”

ALen(IA)        BLen(B)           CLen(S)        DLen(Ch)

23.假設變量Lng為長整形變量,下面不能正常執(zhí)行的語句是

ALng=16384*2                      BLng=4*0.5*16384

CLng=190^2                        D32768*2

24.數(shù)學表達式 對應的正確Visual Basic表達式為

A-b+Sqr(b*b-4*a*c)/2*a

B-b+Sqr(b*b-4*a*c)/(2*a)

C(-b+Sqr(b*b-4*a*c))/(2*a)

D(-b+Sqr(b*b-4*a*c))/ 2*a

25.設Mys1,Mys2均為字符串型變量,Mys1=”Visual Basic”,Mys2=”b”,則下面關系表達式中結果為的是

ALen(Mys1)<>2*InStr(Mys1,”1”)

BMod(Mys1,8,1)>Mys2

CChr(98)&Right(Mys1,4)=”Basic”

DInStr(Left(Mys1,6),”a”)+60

26.在窗體模塊代碼窗口的通用聲明處,可以使用語句說明數(shù)組

Public A(10) As Integer     ② Dim A(10) As Integer

Private A(10)As Integer     ④ Static A(10) As Integer

A①②    B②③    C③④    D①④

27.設A=7,B=4,C=6,,則表達式A Mod3+B^3/C\5的值為

A1       B2       C3       D.出錯

28.下列說法中,錯誤的是

A. 當程序正常結束時,所有沒用Close語句關閉的文件都會自動關閉

B. 在關閉文件或程序結束之前,可以不用Unlock語句對已鎖定的記錄解鎖

C. 可以用不同的文件號同時打開一個隨機文件

D. Output模式打開一個順序文件,即使不對它進行寫操作,原來內(nèi)容也被清除

29.程序中有兩個過程Private Sub Fun1(S As String)Private Sub Fun2(a() As String 6),在調(diào)用過程中用Dim  St(6)  As  String6定義了一個字符串數(shù)組。下面調(diào)用語句中正確的是。

Call Fun1(St(3)) Call Fun2(St) Call Fun1(St) Call Fun2(St(6) )

A.①②   B.①③   C.②③   D.②④

30DrawStyle屬性用于設置圖形方法輸出的線型,它受屬性的限制

AFillStyle    BFillColor   CBorderStyle    DDrawWidth

二、

填空題

1.若窗體有列表框,則List1.List(List1.ListIndex)的值等于List1__Text___屬性值。

2.執(zhí)行下面的程序,當單擊Command1時,列表框List1的第2列表項內(nèi)容是 3 ,第4列表項內(nèi)容是_15_,第5列表項內(nèi)容是  28    。

  Private Sub Command1_Click()

     Dim I As Integer,j As Integer

     For I =1 To 10

        j=I+j

        List1.AddItem j

     Next I

     For I =1 To 4

        List1.RemoveItem List1.ListCount - I

     Next I

  End Sub

3.運行下面的程序,當單擊Command1時,窗體上顯示的第一行內(nèi)容是DCB,第三行內(nèi)容是 D,第四行內(nèi)容是3。

  Private Sub Command1_Click()

    Print Text3

  End Sub

  Private Function Textt As IntegerAs Integer

    Dim i As Integer

    If t=1 Then

       Call Testt-1

       For i = 3 To t Step - 1

           Print ChrAsc(“A”)+ i);

       Next i

Print

     End if

     Test = t

  End Function

4.運行下面的程序,當單擊窗體時,窗體上顯示的第一行內(nèi)容是10 8,第三行內(nèi)容是5 2,第四行內(nèi)容是12  -10。

  Dim x As Integery As Integer

  Private Sub Form_Click()

    Dim a As Integer,b As Integer

    A=5b=3

    Call sub1a,b

    Print a,b

    Print x,y

  End sub

  Private Sub sub1ByVal m As Integer,n As Integer

    Dim y As integer

    X=m+ny=m-n

    M=fun1x,y

    N=fun1yx

  End sub

  Private Function fun1a As Integer,b As IntegerAs Integer

    X=a+by=a-b

    Print x,y

    Fun1=x+y

  End function

5.執(zhí)行下面的程序,當單擊COMMAND1時,picute1中顯示內(nèi)容的第二行與第四行分別是5 6 7 813 14 15 16,picture2中顯示內(nèi)容的第一行和第三行分別是4 8 12 162 6 10 14

  Private Sub Command1_Click()

     Dim a4,4As IntegerI As Integer,j As Integer

     Dim b4,4As Integer

     For I=1 To 4

        S=“”

        For j =1to 4

           AI,j=((I-1*4+j

           S=s&Right(“ & StraI,j)),3

        Next j

        Picture1.Print s

      Next i

      For I=1 To 4

         For j=1 To 4

            B5-jI=aI,j

         Next j

      Next i

      For I=1 to 4

         S=“”

         For j = 1 To 4

            If  Len((CStrbI,j)))<2 Then

               S=s&“” & CStrbI,j))&

            Else

               S=s& CStrbIj))&

            End if

         Next j

         Picture2.Print s

      Next i

  End Sub

6.下面程序的功能時,輸入x的值,利用遞推法分別求出級數(shù)前n項(n=01,23…)之和。

S=a0+a1++an+

其中,

 a 0=1   a n=a n-1 *    n=1,2,3……

計算積數(shù),直到第n項的絕對值小于等于0.001時停止,完善程序,實現(xiàn)以上功能。

  Option Explicit

  Private Sub Command1_Click()

     Dim x As Single, I As Integer s As Single

     Dim a As Single a1 As Single

     X = Text1

     A=1s = a

     List1.AddItems(“&0= & Strs

     Do

        I=I+1

       ____a1=a*x*(3-2*i)/(2*i)______

        S=s+a1

        List1.AddItems(” &CStrI&“)= & Strs

        If  Absa1)〈=0.001 Then

             Text2=i

                Exit do   

        Else

A=a1

        End if

Loop

  End Sub

7.下面程序的功能時,驗證任意一個大于5的奇數(shù)可表示為3個素數(shù)之和。完善程序,實現(xiàn)以上功能。

  Option Base 1

  Private Sub Command1_Click()

Dim P()As Integer,N As Integer,L As Integer

Dim I As IntegerJ As Integer,k As Integer

Dim ch As String

N=InputBox(“輸入一個大于5的奇數(shù)!”)

Label1.Caption=   str(n) & “=”

Call PrimePN

L=UboundP

For I=1 to L

   For J=1 to L

      For k =1 to L

         If p(i)+p(j)+p(k)=n  then

            Ch=CStrPI&+ &CStrPJ))&+ & CStrPk))

            Text1.text = ch

             Exit sub

         End if

      Next k

   Next J

Next I

  End sub

  Private Sub PrimeA()As IntegerN As Integer

Dim I As Integer,Idx As Integer

Dim J As Integer

For I=2 to N

   For J = 2 To SqrI

       If I Mod J =0 Then Exit For

   Next  J

If J>Sqi(I) then

     ___idx=idx+1______

redim preserve A(idx)

a(idx)=I

     end if

8.將20個棋子圍成一圈,按順時針方向從1-20給棋子編號,從中取出棋子的規(guī)則是:從某編號棋子開始取出第1個棋子,然后按順時針方向圍繞周數(shù)棋子,從1數(shù)到2取第2個,再從1數(shù)到3取第3個,再從1數(shù)到4取第4……直到取完。本程序的功能就是找出依照上述規(guī)則取棋子的編號序列,使得最后一個被取棋子的編號為指定的編號。例如:若指定最后取棋子的編號為9,則必須從編號為17的棋子開始取第一個棋子,取棋子的順序是:17,192,611,18……。完善程序,實現(xiàn)以上功能。

Option base 1

Private sub command1_click()

   Dim a(20) as integer,I as integer,k as integer

   Dim n as integer,number as integer,s as string

   Number=val(text2)

   For k=1 to 20

      For I=1 to20    

          A(i)=1

      Next I

  S=_left(cstr(k) & “--”,3)

  Call sub1(a,k,n,s)

  If n=number then

     Text1=s

     Exit for

  End if

Next k

End sub

Private sub sub1(a() as integer,byval idx as integer,n as integer,s as string)

   Dim I as integer,js as integer,sum as integer

   Dim ub as integer,step as integer

   _____ub=ubound(A)__________

   js=1:stemp=1

  a(idx)=0

  do while js<20

       step=step+1

       ____sum=0_______

       do while sum

                idx=idx+1

               if idx>ub then ____idx =idx mod ub___

               sum=sum+a(idx)

        loop

    a(idx)=0

     s=s & left(cstr(idx) & “ ”,3)

    ____js=js+1______

if js mod 10=0 then s=s & vbcrlf

loop

n=idx

end sub

9C盤根目錄下的數(shù)據(jù)文件data.txt中有兩組數(shù)據(jù),第一組數(shù)據(jù)未排序,并以-1表示該組數(shù)據(jù)結束;第二組數(shù)據(jù)按從小到大順序排列。下面程序的功能是,單擊“讀入數(shù)據(jù)”按鈕,將文件中的兩組數(shù)據(jù),分別讀入到AB數(shù)組中,單擊“插入排序”按鈕,則把A數(shù)組的元素按其大小依次插入到B數(shù)組的適當位置,使得B數(shù)組中元素仍為從小到大排列。完善程序,實現(xiàn)以上功能。

Dim a() as integer, b() as integer

Private sub command1_click()

  Dim I as integer,j as integer,n as integer, s as string

     __ open “c:\data.txt” for input as #11__

  do

          input #11,n

          if n=-1 then exit do

          I=I+1

          Redim preserve a(i)

          A(i)=n

          S=s & str(a(i))

  Loop

  Text1=s

   S=””

  ___Do while not eof(1)__

         j=j+1

         redim preserve b(j)

         input #11,b(j)

         s=s & str(b(j))

 loop

 text2=s

close 11

end sub

private sub command2_click()

dim I as integer, j as integer, s as string

for I=1 to ubound(a)

    if a(i)  then

         call change(a(i),1)

    elseif a(i)>b(ubound(b))  then

       ___redim preserve b(ubound(b)+1)___

    b(ubound(b))=a(i)

else

  for j=2 to bound(b)

     if(a(i)>b(j-1))  and a(i)<=b(j)  then call change(a(i),j)

  next j

end if

next I

for I=1 to ubound(b)

     s=s & str(b(i))

next I

text3=s

end sub

private sub change( n as integer,k as integer)

dim I as integer

redim preserve b(ubound(b)+1)

for I=ubound(b)  to k+1 step –1

   _____b(I)=b(I-1)_

next I

____b(k)=n__

end sub