Private Sub Command1_Click()
Text1.Text = ""
Dim AA(1 To 20) As Integer, SS As Integer, SDA As Integer
For I = 1 To 20
Randomize
AA(I) = Int(Rnd * 99 + 1)
Next I
For I = 1 To 19
For J = 1 To 20 - I
If AA(J) > AA(J + 1) Then
SDA = AA(J)
AA(J) = AA(J + 1)
AA(J + 1) = SDA
End If
Next J
Next I
Text1.Text = Text1.Text & "生成的20个随机数:" & vbCrLf
For I = 1 To 20
If AA(I) < 10 Then
Text1.Text = Text1.Text & "0" & AA(I) & Space(3)
Else
Text1.Text = Text1.Text & AA(I) & Space(3)
End If
If I Mod 10 = 0 Then
Text1.Text = Text1.Text & vbCrLf
End If
Next I
Text1.Text = Text1.Text & vbCrLf
Text1.Text = Text1.Text & vbCrLf
Text1.Text = Text1.Text & "能够被5整除的数:" & vbCrLf
For I = 1 To 20
If AA(I) Mod 5 = 0 Then
Text1.Text = Text1.Text & AA(I) & Space(3)
SS = SS + AA(I)
End If
Next I
Text1.Text = Text1.Text & vbCrLf
Text1.Text = Text1.Text & vbCrLf
Text1.Text = Text1.Text & "能够被5整除的数的总和是:" & vbCrLf
Text1.Text = Text1.Text & SS
End Sub