好文档 - 专业文书写作范文服务资料分享网站

南京工业大学VB期末考试模拟题6

天下 分享 时间: 加入收藏 我要投稿 点赞

. .

End Function

Private Sub Form_Click() Print t(1234, 2) Print t(1234, 4) End sub

答案: (1) , (2) (2分)

8.执行程序,单击窗体后在窗体上显示的第一行是 ① ,第二行

是 ② ;若将Sub过程形参表中的ByVal关键字删除,再执行程序后在窗体上显示的第一行是 ③ ,第二行是 ④ 。 Private Sub Value (ByVal m As Integer,ByVal n As Integer) m=m*2 n=n-5

Print\End Sub

Private Sub Form_Click()

Dim x As Integer,y As Integer X=20 : y=15 Call Value(x,y) Print\End Sub

答案: (1) , (2) , (3) , (4) (4分)

9.执行下列程序,在窗体上显示的第一行是 ① ,第二行是 ② ,第三行

是 ③ 。 Option Explicit

Private Sub Command1_Click() dim x As Single, i As Integer x = 1.2 For i = 1 To 3 x = x * i Print fun1(x) Next i End Sub

Private Function fun1(x As Single) As Single Static y As Single y = y + x fun1 = y / 2 End Function

. . .

. .

答案: (1) , (2) , (3) (3分)

10.单击按钮Command1 ,A(1,1)的值是_①__ ,A(1,4)的值是 ② ,A(4,

1)的值是__③ __ ,A(4,4)的值是__④__ 。 Option Base 1

Private Sub Command1_Click()

Dim a() As Integer, i%, j%,k%, n% n=4 : ReDim a(n, n) i=1 : j=n : a(i, j) = 1 For k = 2 To n * n If i+1>n Then

i = n - j + 2: j = 1 ElseIf i+1<=n And j+1>n Then j=j-i : i=1 Else

i=i+1: j=j+1 End If a(i, j) = k Next k For i = 1 To n

For j = 1 To n

Print a(i, j); Next j Print Next i End Sub

11、运行下面程序,当单击窗体时,窗体上显示的容的第一行是____(1)_______,第二行是_____(2)_______。Private Sub test(x As Integer)

x = x * 2 + 1 If x < 6 Then Call test(6) End If x = x * 2 + 1 Form1.Print x End Sub

Private Sub Form_Click() test 2 End Sub

12、添加按钮Command1和文本框Text1,并编写下列代码。执行程序单击命令按钮后,Text1中是_______;将A、B语句交换位置,执行程序单击命令按钮后,Text1中是________。

Option Explicit Sub abc(k,x) Dim i As Integer

. . .

. .

x=1

For i=1 To k x=x*i Next i End Sub

Private Sub Command1_Click()

Dim n As Integer,i As Integer,x As Integer n=0:x=0 For i=1 To 3

Call abc(i,x) 'A语句 n=n+x 'B语句 Next i

Text1.Text=\End Sub

13、运行下面程序,单击命令按钮Command1,则在窗体上显示的容是 ______ 。 Private Sub Command1_Click( ) Dim x As Long,n As Integer x=33:n=5 y=ret(x,n) Print y End Sub

Private Function ret(S As Long,L As Integer)As Long If L>1 Then ret=ret(S,L-1) S=S+2 ret=S End Function

14、下程序的功能是找出此数各位数字的阶乘相加之和等于该数,并在列表框List1中显示。阶乘由Function计算。在(1)、(2)处填上正确容。

Private Sub Command1_Click( ) For k=1 To 1000 a=LTrim(Str(k)) n=0

For i=1 To Len(a) p=Val(Mid(a,i,1)) n=n+fact(p) Next i

If n=k Then_____(1)_______ Next k End Sub

Private Function fact(x) if x<=1 Then fact=1 Else

fact=_____(2) _____

. . .

. .

End If End Function

15、窗体中有一文本框Text1,执行下面程序后,窗体上结果是 _______ ,文本框中输出结果是 _____ 。

Option Explicit

Private Sub Form_Click( ) Dim a As Integer a=2

Call Sub1(a) Text1.Text=a End Sub

Private Sub Sub1(x As Integer) x=x*2+1 If x<10 Then Call Sub1(x) End If x=x*2+1 Print x; End Sub

16、执行下面的程序,在窗体上显示的输出结果的第二行是_____,第三行是_____。 Option Explicit

Dim a As Integer, b As Integer Private Sub Command1_Click( ) Dim c As Integer a = 1: b = 3: c = 5 Print fun(c) print a;b;c Print fun(c) End Sub

Private Function fun(x As Integer)As Single fun = a + b + x/2 a = a + b b = a + x x = b + a End Function

17、一个窗体上有一个命令按钮Command1,下列程序执行后,输出的结果为_________。 Private Sub Command1_Click( ) Dim x As Integer x = 1 Call sort(x) Print x; call sort((x)) Print x; End Sub

. . .

. .

Private Sub sort(y As Integer) y = y+1 End Sub

18、运行下面程序,单击窗体后在窗体上显示的第二行结果是 __(1)___ ;第四行结果是 ___(2) ___。

Dim y As Integer

Private Sub Form_Click() Dim x As Integer x = 1: y = 1

Print \Test

Print \End Sub

Private Sub Test() Dim x As Integer

Print \x = 2: y = 3

Print \End Sub

19、运行下面程序,单击窗体后在窗体上显示的第一行结果是__ (1) __ ;第三行结果是 ___ (2)__ 。

Private Sub Test(x As Integer) Dim i As Integer If x <> 0 Then Call Test(x - 1) Print x End If End Sub

Private Sub Form_Click() Test 3 End Sub

20、运行下面程序,单击窗体后在窗体上显示的第一行结果是__ (1)__ ;第二行结果是__ (2)__。__

Private Function Digit(n As Integer, k As Integer) As Integer Digit = 0 Do While k > 0 Digit = n Mod 10 n = n \\ 10 k = k - 1 Loop

End Function

Private Sub Form_Click() Print Digit(1234, 2) Print Digit(1234, 3)

. . .

南京工业大学VB期末考试模拟题6

..EndFunctionPrivateSubForm_Click()Printt(1234,2)Printt(1234,4)Endsub答案:(1),(2)(2分)8.执行程序,单击窗体后在窗体上
推荐度:
点击下载文档文档为doc格式
06sqs5b29s7f1wl0k4bu3bj0w6iihw013jl
领取福利

微信扫码领取福利

微信扫码分享