《计算机二级vb编程题目含答案》由会员分享,可在线阅读,更多相关《计算机二级vb编程题目含答案(18页珍藏版)》请在金锄头文库上搜索。
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 Sub阳气决定着脏腑的工作能力,而脏腑的工作能力又决定着身体的健康状况和寿命,所以说,想要身体好一点,寿命长一点,就要学会保护好我们的阳气,增加阳气。健康人晒晒太阳,就能吸收到充足的阳气了,但对于老年人和体质特别虚弱的人来说,恐怕吸收来的阳气也不够解燃眉之急的Private Sub Command1_Clic
2、k() 不得删除本行注释Dim i As IntegerOpen App.Path & & yssj.txt For Input As #1For i = 1 To 10Input #1, a(i)Next iClose #1End Sub Private Sub 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_C
3、lick()不得删除本行注释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 + aNext 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 = Inpu
4、tBox(请输入姓名) Write #1, xh, xm Next iClose #1End SubPrivate Sub Command2_Click()不得删除本行注释Dim s as stringOpen App.Path & & Xhxm.txt For Input As #2Do While Not EOF(2)Line Input #2, sText1.Text = Text1.Text & s & vbCrLfLoopClose #2End SubPrivate Sub Command1_Click() ”读取文件”按钮代码不得删除本行注释Dim st As StringText
5、1.Text = Open App.Path & & “jmwb.txt For Input As #1While Not EOF(1)Input #1, stText1.Text = Text1.Text + st + vbCrLfWendClose #1End SubPrivate 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
6、 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 * 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
7、 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 char 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 = 输入的是字
8、母 Else: Label1.Caption = 输入的是其它符号 End IfElse: Label1.Caption = 输入的是数字End IfEnd SubPrivate Sub Command1_Click()Text1.Text = UCase(Text1.Tag)End SubPrivate Sub Command2_Click()Text1.Text = LCase(Text1.Tag)End SubPrivate Sub Command3_Click()Text1.Text = Text1.TagEnd SubPrivate Sub Text1_KeyUp(KeyCode A
9、s Integer, Shift As Integer)对于文本框控件中输入的每次键盘按键弹起事件做一次文本内容保存Text1.Tag = Text1.Text 用Text1.Tag属性作为保存textbox控件文本内容的临时存储区End SubPrivate Sub command1_Click() 不得删除本行注释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 =
10、 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.Text = maxText5.Text = minEnd SubPrivate Sub Command1_Click()Dim a As IntegerIf Not IsNumeric(Text1.Text) ThenMsgBox 请输入数字!, 48, 输入的不是数字Else a
11、= 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.SelLength = Len(Text1.Text)End SubPrivate Sub Command1_Click() 不得删除本行注释Dim n As Integer, i As Integern = Val(Text1.Text)If n 0 Or (Not IsNume
12、ric(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 Command1_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 Su
13、bPrivate 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 Then T1.Text = AaaEnd IfIf Op2 Then T1.Text = BbbEnd IfEnd SubPrivate Sub Command1_Click() 不得删除本行注释Dim i As Integer, n As Integer, s A
14、s 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 = sEnd SubPrivate Sub Command1_Click() 不得删除本行注释Dim a As Integera = Val(Text1.Text)Text2.Text = zh(a) zh过程在原本的程序代码中已经有了直接可用End SubPrivate Sub Command1_Click() 不得删除本行注释Dim x As Doub