=65Andx(N)EndSubPrivateSubCommand1_Click" />
搜档网
当前位置:搜档网 › 编程题解答2

编程题解答2

编程题解答2
编程题解答2

Private Sub Command1_Click()

Dim x(1 To 20) As Integer, N As Integer

For N = 1 To 20

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

Text1.Text = Text1.Text & x(N) & " "

Next N

For N = 1 To 20

If x(N) >= 65 And x(N) <= 90 Then Text2.Text = Text2.Text & Chr(x(N)) & " " Next N

End Sub

Private Sub Command1_Click()

Dim a As Integer, b As Integer, c As Integer, d As Integer

a = Val(Text1.Text)

b = Val(Text2.Text)

c = a - b

d = a + b

If a <= 0 Or b <= 0 Or c <= 0 Then

MsgBox "请输入自然数且第一个数应该大于第二个数!", , "输入出错"

ElseIf Sqr(c) = Int(Sqr(c)) And Sqr(d) = Int(Sqr(d)) Then

Text3.Text = "yes"

Else

Text3.Text = "no"

End If

End Sub

Private Sub Command1_Click()

If Len(Text1.Text) < 15 Then

MsgBox "字符串长度不足15!", , "请补足" Text1.SetFocus

Else

Text2.Text = Left(Text1.Text, 5)

Text3.Text = Right(Text1.Text, 5)

Text4.Text = Text2.Text & Text3.Text

End If

End Sub

Private Sub Command1_Click()

Dim N As Integer, i As Integer

If Not IsNumeric(Text1.Text) Then MsgBox "请输入数字!", , "输入的不是数字" Text1.SetFocus

Text1.SelStart = 0

Text1.SelLength = Len(Text1.Text)

Else: N = Val(Text1.Text)

Text2.Text = ""

For i = 1 To N

If Sqr(i) = Int(Sqr(i)) Then Text2.Text = Text2.Text & i & " "

Next i

End If

End Sub

Private Sub Command1_Click()

Dim a As String

Open App.Path & "\" & "zfcwj.txt" For Input As #1

Line Input #1, a '在此不能用Input #1, a语句,会将文本文件中双引号视作字符串标志而将其省略Text1.Text = a

Text2.Text = Len(a)

End Sub

Private Sub Command1_Click()

Dim i As Integer

Open App.Path & "\" & "xzfwj.txt" For Input As #1

For i = 1 To 25

Input #1, N(i)

List1.AddItem N(i)

Next i

Close #1

End Sub

Private Sub Command2_Click()

Dim i As Integer

For i = 1 To 25

If Asc(N(i)) > Asc("D") Then List2.AddItem N(i)

Next i

End Sub

Private Sub Command1_Click()

Text2.Text = zh(Text1.Text) 'zh过程在原本的程序代码中已经有了,直接可用End Sub

Private Sub Command1_Click()

Dim i As Integer

Open App.Path & "\" & "Y24.txt" For Input As #1

For i = 1 To 20

Input #1, Arr(i)

Next i

Close #1

Text1.Text = "Y24.txt文件数据已读入"

End Sub

Private Sub Command2_Click()

Dim s As Integer, i As Integer

s = 0

For i = 1 To 20

s = s + Arr(i)

Next i

Text1.Text = s

End Sub

Option Explicit

Dim a(1 To 100) As String

Private Sub Command1_Click()

Dim i As Integer

Text1.Text = ""

For i = 1 To 100

a(i) = sczf ‘利用sczf过程生成随机英文字母

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

Next i

End Sub

Private Sub Command2_Click()

Dim i As Integer

Dim char As String, S As Integer

char = Text2.Text

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

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

S = 0

For i = 1 To 100

If Asc(a(i)) = Asc(char) Then S = S + 1

Next i

Text3.Text = Str(S)

Else

MsgBox "统计目标非英文字母", , "重新输入"

Text2.SetFocus

Text2.SelStart = 0

Text2.SelLength = Len(Text2.Text) End If End Sub

Private Sub Command1_Click()

'''不得删改本行注释

Dim i As Integer

Open App.Path & "\" & "rywj.txt" For Input As #1 For i = 1 To 10

Input #1, Arr(i)

Next i

Close #1

End Sub Private Sub Command2_Click()

'''不得删改本行注释

Text1.Text = ""

Dim i As Integer

For i = 1 To 10

If Left(Arr(i), 1) = "黄" Or Left(Arr(i), 1) = "" Then Text1.Text = Text1.Text & Arr(i) & " "

End if

Next i

End Sub

相关主题