2022年2022年江苏计算机二级VB填空题 .pdf

上传人:C****o 文档编号:39683544 上传时间:2022-09-07 格式:PDF 页数:25 大小:227.64KB
返回 下载 相关 举报
2022年2022年江苏计算机二级VB填空题 .pdf_第1页
第1页 / 共25页
2022年2022年江苏计算机二级VB填空题 .pdf_第2页
第2页 / 共25页
点击查看更多>>
资源描述

《2022年2022年江苏计算机二级VB填空题 .pdf》由会员分享,可在线阅读,更多相关《2022年2022年江苏计算机二级VB填空题 .pdf(25页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

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

17、eger)As String Dim r As Integer If n 0 Then r=n Mod k Tran=Tran(n k,k)&r Print r End If End Function4 1.已知在列表框中有5 个列表项,从上到下内容分别为0、1、2、3、4。执行下面程序,名师资料总结-精品资料欢迎下载-名师精心整理-第 13 页,共 25 页 -.Word 资料单击窗体后,列表框上显示的第二个列表项内容是(1),列表框中共有(2)项。Option Explicit Private Sub Form_Click()Dim i As Integer For i=0 To List

18、1.ListCount/2-1 List1.RemoveItem i Next i End Sub 2.执行下面程序,单击命令按钮Command1,在弹出的InputBox 对话框中输入8,并按“确定”按钮,则a(1)的值是(3),a(5)的值是(4)。Option Explicit Option Base 1 Private Sub Command1_Click()Dim a()As Integer,i As Integer,n As Integer n=InputBox(输入 N,8)ReDim a(n)Call process(a,1,1)For i=1 To n Print a(i)N

19、ext i 名师资料总结-精品资料欢迎下载-名师精心整理-第 14 页,共 25 页 -.Word 资料End Sub Private Sub process(a()As Integer,m As Integer,n As Integer)Dim i As Integer i=UBound(a)a(i)=m a(i-1)=n i=i-2 Do While i=1 a(i)=a(i+1)+a(i+2)i=i-1 Loop End Sub 3.执行下列程序,单击Command1按钮后,窗体上第一行为(5),第二行为(6),最后一行为(7)。Option Explicit Dim n As Inte

20、ger Private Sub Command1_Click()Dim i As Integer n=1 For i=1 To 5 Call Sub1(i,n)名师资料总结-精品资料欢迎下载-名师精心整理-第 15 页,共 25 页 -.Word 资料Print n Next i Print i End Sub Private Sub Sub1(x As Integer,y As Integer)Dim i As Integer n=n+2 x=x+2 y=y+x End Sub 4.执行下面程序,单击Command1按钮,则在窗体上显示的第一行内容是(8),第三行内容是(9),最后一行内容是

21、(10)。Option Explicit Private Sub Command1_Click()Dim a As Integer,b As Integer a=3 b=1 Call P1(a,b)Print b Call P1(b,a)名师资料总结-精品资料欢迎下载-名师精心整理-第 16 页,共 25 页 -.Word 资料Print b End Sub Private Sub P1(x As Integer,ByVal y As Integer)Static z As Integer x=x+z y=x-z z=10-y Print z End Sub 5 1.执行下面的程序,单击命令按

22、钮Command1,则窗体上显示的第一行是(1),最后一行是(2)。Option Explicit Private Sub Command1_Click()Dim m(10)As Integer,k As Integer,x As Integer For k=1 To 10 m(k)=11-k Next k x=3 Print m(2+m(x)名师资料总结-精品资料欢迎下载-名师精心整理-第 17 页,共 25 页 -.Word 资料Print m(m(x-1)+m(x+1)-6)*2 If m(2+m(x)3 Then Print x+m(k+m(k-1)-9)Else Print x-m(

23、k+m(k-1)-9)End If End Sub 2.执行下面的程序,单击命令按钮Command1,则图片框Picture2中显示的第一行是(3),第二行是(4),第三行是(5)。Option Explicit Option Base 1 Private Sub Command1_Click()Dim sa(3,3)As String*1,i As Integer,j As Integer,s As String,k As Integer s=ABCDEFXYZ k=1 For i=1 To 3 For j=1 To 3 sa(i,j)=Mid(s,k,1)Picture1.Print sa

24、(i,j);k=k+1 Next j 名师资料总结-精品资料欢迎下载-名师精心整理-第 18 页,共 25 页 -.Word 资料Picture1.Print Next i For i=1 To 3 For j=1 To 3 k=(Asc(sa(i,j)-Asc(A)+i+j)Mod 26 sa(i,j)=Chr(k+Asc(A)Picture2.Print sa(i,j);Next j Picture2.Print Next i End Sub 3.执行下面的程序,单击命令按钮Command1,则窗体上显示的第一行是(6),第二行是(7),最后一行是(8)。Option Explicit O

25、ption Base 1 Private Sub Command1_Click()Dim a As Integer,b As Integer,c As Integer a=6 b=20 c=Fun(a,b)名师资料总结-精品资料欢迎下载-名师精心整理-第 19 页,共 25 页 -.Word 资料Print b End Sub Private Function Fun(ByVal x As Integer,y As Integer)As Integer x=x-2 y=y-3 If x=0 Or y=0 Then Fun=1 Else Fun=Fun(x-2,y-3)End If Print

26、x End Function 4.执行下面程序,单击命令按钮Command1,则在窗体上显示的第二行是(9),最后一行是(10)。Option Explicit Dim b As Integer Private Sub Command1_Click()Dim a As Integer,i As Integer a=8 For i=1 To 3 名师资料总结-精品资料欢迎下载-名师精心整理-第 20 页,共 25 页 -.Word 资料Print F(a)Next i End Sub Function F(a As Integer)As Integer Static c As Integer b

27、=b+1 c=c+2 F=a+b-c End Function 6 1.执行下面程序,单击命令按钮Command1,若文本框 Text1 中生成的数据为“8 6 6 3 4 8”,则列表框List1中共输出(1)行数据,其中第一行为(2),最后一行为(3)。Option Explicit Private Sub Command1_Click()运行Dim a(6)As Integer,b(1 To 10)As Integer Dim i As Integer 名师资料总结-精品资料欢迎下载-名师精心整理-第 21 页,共 25 页 -.Word 资料For i=1 To 6 a(i)=1+In

28、t(Rnd*10)Text1.Text=Text1.Text&Str(a(i)Next i Call num(a,b)For i=1 To 10 If b(i)0 Then List1.AddItem b(i)Next i End Sub Private Sub num(x()As Integer,y()As Integer)Dim i As Integer For i=1 To 6 y(x(i)=y(x(i)+1 Next i End Sub 2.执行下面程序,单击命令按钮Command1,则 窗 体 上 输 出 的data 数组元素个数为(4),最后一行是(5)。Option Explic

29、it Option Base 1 Private Sub Command1_Click()名师资料总结-精品资料欢迎下载-名师精心整理-第 22 页,共 25 页 -.Word 资料Dim st As String,char As String Dim data()As String,i As Integer,j As Integer st=66*97*115*105*99*For i=1 To Len(st)If Mid(st,i,1)*Then char=char&Mid(st,i,1)Else j=j+1 ReDim Preserve data(j)data(j)=char char=E

30、nd If Next i Print data数组元素个数为;j Print Conver(data)End Sub Private Function Conver(a()As String)As String Dim i As Integer For i=1 To UBound(a)Conver=Conver&Chr(Val(a(i)字母 A、a 的 ASCII 码分别为65、97 Next i 名师资料总结-精品资料欢迎下载-名师精心整理-第 23 页,共 25 页 -.Word 资料End Function 3.执行下面程序,单击命令按钮Command1,则窗体上显示的第三行是(6),最

31、后一行是(7)。Option Explicit Dim i As Integer Private Sub Command1_Click()Print Test(D)End Sub Private Function Test(t As String)As Integer If t=A Then Call Test(Chr(Asc(t)-1)Print t i=i+1 End If Test=i End Function 4.执行下面程序,单击窗体,在弹出的InputBox 对话框中输入“4”,并单击“确定”按钮,则数组元素a(2,2)的值是(8),a(3,2)的值是(9),a(4,3)的值是名师

32、资料总结-精品资料欢迎下载-名师精心整理-第 24 页,共 25 页 -.Word 资料(10)。Option Explicit Private Sub Form_Click()Dim a()As Integer,n As Integer Dim i As Integer,j As Integer n=InputBox(请输入行数:,4)ReDim a(0 To n,0 To n)For i=1 To n For j=1 To i If i=1 Or i=j Then a(i,j)=1 Else a(i,j)=a(i-1,j-1)+a(i-1,j)End If Print a(i,j);Next j Print Next i End Sub 名师资料总结-精品资料欢迎下载-名师精心整理-第 25 页,共 25 页 -

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高考资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁