计算机二级VB编程题目含答案

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

计算机二级VB编程题目含答案

Private Sub Command1_Click()

Dim n As Integer, i As Integer, s As Double

n = Val(Text1.Text)

s = 0

For i = 1 To n

s = s + i ^ 2

Next i

Text2.Text = s

End Sub

Private Sub Command1_Click()

''' 不得删除本行注释

Dim i As Integer Open App.Path & "\" & "yssj.txt" For Input As #1

For i = 1 To 10

Input #1, a(i)

Next i

Close #1

End Sub

Private Sub Command2_Click() ''' 不得删除本行注释

Dim i As Integer Text1.Text = ""

For i = 1 To 10

If a(i) Mod 3 = 2 Then

Text1.Text = Text1.Text & Str(a(i))

End If

Next i

End Sub

Private Sub command1_Click()

'''不得删除本行注释

Dim a As Integer, b As Double, i As Integer, n As Integer

n = Val(Text1.Text)

a = 0

b = 0

For i = 1 To n

a = a + i

b = b + a

Next i

Text2.Text = b

End Sub

Private Sub Command1_Click() '''不得删除本行注释Dim i%, xh$, xm$ Open App.Path & "\" & "Xhxm.txt" For Output As #1 For i = 1 To 3

xh = InputBox("请输入学号")

xm = InputBox("请输入姓名")

Write #1, xh, xm Next i

Close #1

End Sub Private Sub Command2_Click() '''不得删除本行注释Dim s as string Open App.Path & "\" & "Xhxm.txt" For Input As #2

Do While Not EOF(2)

Line Input #2, s Text1.Text = Text1.Text & s & vbCrLf

Loop

Close #2

End Sub

Private Sub Command1_Click() ‘”读取文件”按钮代码

'''不得删除本行注释Dim st As String Text1.Text = "" Open App.Path & "\" & “jmwb.txt" For Input As #1 While Not EOF(1) Input #1, st

Text1.Text = Text1.Text + st + vbCrLf

Wend

Close #1

End Sub Private Sub Command2_Click() Dim s As String, co As String, c As String,

Dim n As Integer, i As Integer, p As Integer

s = 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 i

Text2.Text = co

End Sub

Private Sub command1_click() '''不得删除本行注释For N = 1 To 15

x(N) = Int(Rnd * 91 + 10)

Text1.Text = Text1.Text + Str(x(N))

Next N

End Sub

Private Sub Command2_Click() '''不得删除本行注释Dim m As Integer, K As Integer

For 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 N

End Sub

Private Sub Command1_Click()

Dim char As String * 1

char = Trim(Text1.Text)

If Not IsNumeric(char) Then

If (Asc(char) >= 65 And Asc(char) <= 90) Or _

(Asc(char) >= 97 And Asc(char) <= 120) Then

Label1.Caption = "输入的是字母"

Else: Label1.Caption = "输入的是其它符号"

End If

Else: Label1.Caption = "输入的是数字"

End If

End Sub

相关文档
最新文档