2023年计算机二级VB编程题目含答案.doc

上传人:知****量 文档编号:58271824 上传时间:2022-11-07 格式:DOC 页数:23 大小:1.41MB
返回 下载 相关 举报
2023年计算机二级VB编程题目含答案.doc_第1页
第1页 / 共23页
2023年计算机二级VB编程题目含答案.doc_第2页
第2页 / 共23页
点击查看更多>>
资源描述

《2023年计算机二级VB编程题目含答案.doc》由会员分享,可在线阅读,更多相关《2023年计算机二级VB编程题目含答案.doc(23页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、Private Sub Command1_Click()Dim n As Integer,i As Integer,s As Doublen = Val(Text1.Text)s = 0For i = 1 To n s = s + i 2Next iText2.Text = sEnd SubPrivate Sub Command1_Click() 不得删除本行注释Dim i As IntegerOpen App.Path & & yssj.txt For Input As #1For i = 1 To 10Input #1,a(i)Next iClose #1End Sub Private S

2、ub Command2_Click() 不得删除本行注释Dim i As IntegerText1.Text = For i = 1 To 10If a(i) Mod 3 = 2 Then Text1.Text = Text1.Text & Str(a(i)End IfNext iEnd SubPrivate Sub command1_Click()不得删除本行注释Dim a As Integer,b As Double,i As Integer,n As Integern = Val(Text1.Text)a = 0b = 0For i = 1 To na = a + ib = b + aN

3、ext iText2.Text = bEnd Sub Private Sub Command1_Click()不得删除本行注释Dim i%,xh$,xm$Open App.Path & & Xhxm.txt For Output As #1For i = 1 To 3 xh = InputBox(请输入学号) xm = InputBox(请输入姓名) Write #1,xh,xm Next iClose #1End SubPrivate Sub Command2_Click()不得删除本行注释Dim s as stringOpen App.Path & & Xhxm.txt For Input

4、 As #2Do While Not EOF(2)Line Input #2,sText1.Text = Text1.Text & s & vbCrLfLoopClose #2End SubPrivate Sub Command1_Click() ”读取文献”按钮代码不得删除本行注释Dim st As StringText1.Text = Open App.Path & & “jmwb.txt For Input As #1While Not EOF(1)Input #1,stText1.Text = Text1.Text + st + vbCrLfWendClose #1End SubPri

5、vate Sub Command2_Click()Dim s As String,co As String,c As String,Dim n As Integer,i As Integer,p As Integers = Trim(Text1.Text)n = Len(s)co = For i = 1 To n c = Mid(s,i,1) p = Asc(c) + 5 co = co + Chr(p)Next iText2.Text = coEnd SubPrivate Sub command1_click()不得删除本行注释For N = 1 To 15 x(N) = Int(Rnd *

6、 91 + 10) Text1.Text = Text1.Text + Str(x(N)Next NEnd SubPrivate Sub Command2_Click()不得删除本行注释Dim m As Integer,K As IntegerFor N = 1 To 15 For m = N + 1 To 15 If x(m) x(N) Then K = x(N) x(N) = x(m) x(m) = K End If Next m Text2.Text = Text2.Text + Str(x(N)Next NEnd SubPrivate Sub Command1_Click()Dim c

7、har As String * 1char = Trim(Text1.Text)If Not IsNumeric(char) Then If (Asc(char) = 65 And Asc(char) = 97 And Asc(char) = 120) Then Label1.Caption = 输入是字母 Else:Label1.Caption = 输入是其他符号 End IfElse:Label1.Caption = 输入是数字End IfEnd SubPrivate Sub Command1_Click()Text1.Text = UCase(Text1.Tag)End SubPriva

8、te Sub Command2_Click()Text1.Text = LCase(Text1.Tag)End SubPrivate Sub Command3_Click()Text1.Text = Text1.TagEnd SubPrivate Sub Text1_KeyUp(KeyCode As Integer,Shift As Integer)对于文本框控件中输入每次键盘按键弹起事件做一次文本内容保存Text1.Tag = Text1.Text 用Text1.Tag属性作为保存textbox控件文本内容暂时存储区End SubPrivate Sub command1_Click() 不得

9、删除本行注释Dim a As Integer,b As Integer,c As IntegerDim max As Integer,min As Integera = Val(Text1.Text)b = Val(Text2.Text)c = Val(Text3.Text)max = a + b + Abs(a - b)max = max / 2min = a + b - Abs(a - b)min = min / 2max = max + c + Abs(max - c)max = max / 2min = min + c - Abs(min - c)min = min / 2Text4.

10、Text = maxText5.Text = minEnd SubPrivate Sub Command1_Click()Dim a As IntegerIf Not IsNumeric(Text1.Text) ThenMsgBox 请输入数字!,48,输入不是数字Else a = Val(Text1.Text)If (a Mod 4 = 0 And a Mod 100 0) Or a Mod 400 = 0 Then Text2.Text = 闰年Else:Text2.Text = 非闰年End IfEnd ifText1.SetFocusText1.SelStart = 0Text1.Se

11、lLength = Len(Text1.Text)End SubPrivate Sub Command1_Click() 不得删除本行注释Dim n As Integer,i As Integern = Val(Text1.Text)If n 0 Or (Not IsNumeric(Text1.Text) Then MsgBox 请输入正整数,48,输入不是正整数Open App.Path & & jfwj.txt For Output As #1For i = 1 To nPrint #1,String(i,*)Next iClose #1End SubPrivate Sub Command

12、1_Click() 不得删除本行注释Dim i As IntegerFor i = 1 To 200If i Mod 3 = 0 And i Mod 7 = 0 ThenText1.Text = Text1.Text + Str(i)End IfNextEnd SubPrivate Sub Command1_Click() 不得删除本行注释Dim sum As Single,i As IntegerOpen App.Path & & Jsdata.txt For Input As #1For i = 1 To 15 Input #1,Arr(i)Next iClose #1If Op1 The

13、n T1.Text = AaaEnd IfIf Op2 Then T1.Text = BbbEnd IfEnd SubPrivate Sub Command1_Click() 不得删除本行注释Dim i As Integer,n As Integer,s As Integern = Val(Text1.Text)If n 0 Or (Not IsNumeric(Text1.Text) Then MsgBox 请输入正整数,48,输入不是正整数s = 0For i = 1 To n If i Mod 3 = 0 Then s = s + i End IfNext iText2.Text = sE

14、nd SubPrivate Sub Command1_Click() 不得删除本行注释Dim a As Integera = Val(Text1.Text)Text2.Text = zh(a) zh过程在原本程序代码中已有了直接可用End SubPrivate Sub Command1_Click() 不得删除本行注释Dim x As DoubleDim y As Doublex = Val(Text1.Text)If x 10 Then y = x - 1ElseIf x 20 Then y = 2 * x - 1Else:y = 3 * x - 1End IfText2.Text = yE

15、nd SubPrivate Sub Command1_Click() 不得删除本行注释Text1.Text = Open App.Path & & zfwj.txt For Input As #1For i = 1 To 10 Input #1,a(i) Text1.Text = Text1.Text & & a(i)Next iClose #1End SubPrivate Sub Command2_Click() 不得删除本行注释Dim t As StringText2.Text = For i = 1 To 10 t = a(i) a(i) = a(10 - i + 1) a(10 - i

16、 + 1) = tText2.Text = Text2.Text & & a(i)Next iEnd SubPrivate Sub Command1_Click()Dim a As IntegerDim b As Integera = Val(Text1.Text)b = Val(Text2.Text)Label1.Caption = Int(Rnd() * (b - a + 1) + a)Label2.Caption = Int(Rnd() * (b - a + 1) + a)Label3.Caption = Int(Rnd() * (b - a + 1) + a)End SubPrivat

17、e Sub Command1_Click()Dim s as stringOpen App.Path & & Bdata.txt For Input As #1Do While Not EOF(1)Line Input #1,sText1.Text = Text1.Text + s + Chr(13) + Chr(10)LoopClose #1End SubPrivate Sub Command1_Click()不得删改本行注释Dim n As Integern = Val(Text1.Text)If n 999 Then MsgBox 请输入三位正整数,输入犯错Else:Text2.Text

18、 = Int(n Mod 10) Text3.Text = Int(n Mod 100) / 10) Text4.Text = Int(n / 100)End IfEnd SubPrivate Sub Command1_Click()产生按钮代码i = List1.ListIndexFor i = 0 To 9 List1.AddItem Int(90 * Rnd + 10)Next iEnd SubPrivate Sub Command3_Click() 清除按钮代码List1.ClearList2.ClearEnd SubPrivate Sub Command2_Click()不得删改本行

19、注释Dim n As Double,j As Integeri = List1.ListIndexFor i = List1.ListCount - 1 To 0 Step -1 n = Val(List1.List(i) If n Mod 2 = 1 Then List2.AddItem n List1.RemoveItem i End IfNext iEnd SubPrivate Sub Command1_Click() ”读入数据”按钮代码不得删除本行注释Dim st As StringText1.Text = Open App.Path & & yy.txt For Input As

20、#1While Not EOF(1)Input #1,stText1.Text = Text1.Text + st + vbCrLfWendClose #1End SubPrivate Sub Command2_Click()不得删除本行注释Dim x As String,y As String * 1,n As Integer,i As Integer,p As Integerx = Trim(Text1.Text)n = Len(x)p = 0For i = 1 To n y = UCase(Mid(x,i,1) If y = A And y k Then List1.AddItem nNext nEnd Sub

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

当前位置:首页 > 教育专区 > 初中资料

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

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