收藏 分销(赏)

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

上传人:精*** 文档编号:4317140 上传时间:2024-09-05 格式:DOC 页数:23 大小:1.41MB
下载 相关 举报
2023年计算机二级VB编程题目含答案.doc_第1页
第1页 / 共23页
2023年计算机二级VB编程题目含答案.doc_第2页
第2页 / 共23页
2023年计算机二级VB编程题目含答案.doc_第3页
第3页 / 共23页
2023年计算机二级VB编程题目含答案.doc_第4页
第4页 / 共23页
2023年计算机二级VB编程题目含答案.doc_第5页
第5页 / 共23页
点击查看更多>>
资源描述

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 = y

15、End 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 -

16、i + 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 SubPriva

17、te 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.Tex

18、t = 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

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
搜索标签

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服