2022年2022年江苏计算机二级VB填空题 .pdf
《2022年2022年江苏计算机二级VB填空题 .pdf》由会员分享,可在线阅读,更多相关《2022年2022年江苏计算机二级VB填空题 .pdf(25页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、.Word 资料填空题 1 1.执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是(1),最后一行是(2)。Option Explicit Option Base 1 Private Sub Command1_Click()Dim n As Long,k As Integer,a()As Integer n=123456789 Do k=k+1 ReDim Preserve a(k)a(k)=n Mod 100 n=n 100 Loop Until n=0 For k=1 To UBound(a)Print fun(a(k)Next k End Sub Private Func
2、tion fun(n As Integer)As Integer Dim k As Integer k=n Mod 10 名师资料总结-精品资料欢迎下载-名师精心整理-第 1 页,共 25 页 -.Word 资料fun=k*10+(n 10)End Function2.执行下面程序,单击命令按钮Command1,则数组元素a(2,1)的值是(3),a(1,2)的值是(4)。Option Explicit Option Base 1 Private Sub Command1_Click()Dim a(3,3)As Integer,i As Integer,k As Integer Dim n A
3、s Integer n=9 For k=1 To 3 For i=1 To 3 a(i,k)=n n=n-1 Next i Next k For i=1 To 3 For k=1 To 3 Print a(i,k);Next k 名师资料总结-精品资料欢迎下载-名师精心整理-第 2 页,共 25 页 -.Word 资料Print Next i End Sub 3.执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是(5),第二行是(6),第三行是(7)。Option Explicit Private Sub Command1_Click()Dim i As Integer,a A
4、s Integer,b As Integer a=1 b=2 i=a Do While fun(i,b)=7 i=i+a b=b+1 Print i Loop End Sub Private Function fun(ByVal x As Integer,y As Integer)As Integer x=x+1 y=y+1 名师资料总结-精品资料欢迎下载-名师精心整理-第 3 页,共 25 页 -.Word 资料fun=x+y Print fun End Function4.执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是(8),第二行是(9),最后一行是(10)。Opti
5、on Explicit Dim k As Integer k 为模块级变量Private Sub Command1_Click()Dim N As Integer,M As Integer,Lcm As Integer N=6 M=9 Lcm=Rec(N,M)Print Lcm End Sub Private Function Rec(A As Integer,B As Integer)As Integer k=k+1 Print A If A Mod B=0 Then Rec=A Else 名师资料总结-精品资料欢迎下载-名师精心整理-第 4 页,共 25 页 -.Word 资料Rec=Re
6、c(A+A/k,B)End If End Function2 5.执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是(1),第三行是(2)。Option Explicit Option Base 1 Private Sub Command1_Click()Dim s As String,k As Integer Dim q As String,a()As String,n As Integer s=ABCDEFG n=1 Do k=k+1 ReDim Preserve a(k)a(k)=Mid(s,n,n)n=n+1 Loop While n+Len(a(k)=Len(s)Fo
7、r n=1 To UBound(a)名师资料总结-精品资料欢迎下载-名师精心整理-第 5 页,共 25 页 -.Word 资料q=Call sub1(a(n),q)Print q Next n End Sub Private Sub sub1(s As String,q As String)Dim i As Integer For i=1 To Len(s)q=Mid(s,i,1)&q Next i End Sub6.执行下面程序,单击命令按钮Command1,则数组元素a(1,2)的值是(3),a(3,1)的值是(4)。Option Explicit Option Base 1 Privat
8、e Sub Command1_Click()Dim a(3,3)As Integer,i As Integer,j As Integer For i=1 To 3 For j=1 To 3 If(i+j)Mod 2=0 Then 名师资料总结-精品资料欢迎下载-名师精心整理-第 6 页,共 25 页 -.Word 资料a(i,j)=i+j Else a(i,j)=(i*3+j)/2 End If Print a(i,j);Next j Print Next i End Sub7.执行下面程序,单击命令按钮Command1,则数组元素a(5)的值是(5),窗体上显示的第二行是(6),第三行是(7
9、)。Option Explicit Option Base 1 Private Sub Command1_Click()Dim i As Integer,a(5)As Integer,j As Integer For i=1 To 5 a(i)=2*i-1 Print a(i);Next i Print For i=a(5)To a(3)Step-1 名师资料总结-精品资料欢迎下载-名师精心整理-第 7 页,共 25 页 -.Word 资料Print fun(i,a(i-4)Next i End Sub Private Function fun(a As Integer,b As Intege
10、r)As Integer a=a-1 b=b-1 fun=(a+b)/2 End Function8.执行下面程序,单击命令按钮Command1,则数组元素yz(1)的值是(8),数组元素 yz(3)的值是(9),窗体上显示的最后一行是(10)。Option Explicit Option Base 1 Private Sub Command1_Click()Dim n As Integer,yz()As Integer,s As Integer Dim i As Integer n=12 Call sub1(n,yz)For i=1 To UBound(yz)s=s+yz(i)Print y
11、z(i)Next i 名师资料总结-精品资料欢迎下载-名师精心整理-第 8 页,共 25 页 -.Word 资料Print s End Sub Private Sub sub1(n As Integer,a()As Integer)Dim k As Integer,i As Integer For i=2 To n/2 If n Mod i=0 Then k=k+1 ReDim Preserve a(k)a(k)=i End If Next i End Sub3 9.执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是(1),第三行是(2)。Option Explicit Opt
12、ion Base 1 Private Sub Command1_Click()Dim s As String,k As Integer,a()As String,i As Integer s=VBASIC 名师资料总结-精品资料欢迎下载-名师精心整理-第 9 页,共 25 页 -.Word 资料i=1 Do k=k+1 ReDim Preserve a(k)a(k)=Mid(s,i,i)i=i+1 Loop While i+Len(a(k)-1=Len(s)For k=1 To UBound(a)Print fun(a(k)Next k End Sub Private Function fun
13、(s As String)As String Dim k As Integer,t As String For k=Len(s)To 1 Step-1 t=t&Mid(s,k,1)Next k fun=t End Function10.执行下面程序,单击命令按钮Command1,则数组元素a(2,1)的值是(3),a(1,3)的值是(4)。名师资料总结-精品资料欢迎下载-名师精心整理-第 10 页,共 25 页 -.Word 资料Option Explicit Option Base 1 Private Sub Command1_Click()Dim a(3,3)As Integer,i As
14、 Integer,j As Integer Dim k As Integer,n As Integer k=2 n=1 Do While k=6 For i=1 To 3 For j=1 To 3 If i+j=k Then a(i,j)=n:n=n+1 Next j Next i k=k+1 Loop For i=1 To 3 For j=1 To 3 Print a(i,j);Next j Print Next i End Sub 名师资料总结-精品资料欢迎下载-名师精心整理-第 11 页,共 25 页 -.Word 资料11.执行下面程序,单击命令按钮Command1,则数组元素a(3)
15、的值是(5),窗体上显示的第二行是(6),第四行是(7)。Option Explicit Option Base 1 Private Sub Command1_Click()Dim i As Integer,a(5)As Integer,j As Integer For i=1 To 5 a(i)=2*i-1 Print a(i);Next i Print j=UBound(a)For i=j To 2 Step-1 Print fun(a(i),a(i-1)Next i End Sub Private Function fun(ByVal a As Integer,b As Integer)
16、As Integer fun=(a+b)/2 a=a+1 b=b+1 End Function名师资料总结-精品资料欢迎下载-名师精心整理-第 12 页,共 25 页 -.Word 资料12.执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是(8),第二行是(9),最后一行是(10)。Option Explicit Private Sub Command1_Click()Dim n As Integer,k As Integer n=59 k=5 Print Tran(n,k)End Sub Private Function Tran(n As Integer,k As Int
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年2022年江苏计算机二级VB填空题 2022 江苏 计算机 二级 VB 填空
限制150内