Private Sub CommandButton1_Click() Dim A(20), Sum As Integer Sum = 0 For i = 1 To 20 A(i) = Int(Rnd * 20) If A(i) > 3 Then Sum = Sum + A(i) TextBox1.Text = TextBox1.Text & A(i) & " " TextBox2.Text = Sum Next i If TextBox1.Text <> "" Then CommandButton1.Enabled = False CommandButton2.Enabled = True End If End Sub
Private Sub CommandButton2_Click() If TextBox1.Text <> "" Then CommandButton1.Enabled = True TextBox1.Text = "" TextBox2.Text = "" CommandButton2.Enabled = False End Sub
Dim A(20), Sum As Integer
Sum = 0
For i = 1 To 20
A(i) = Int(Rnd * 20)
If A(i) > 3 Then Sum = Sum + A(i)
TextBox1.Text = TextBox1.Text & A(i) & " "
TextBox2.Text = Sum Next i
If TextBox1.Text <> "" Then
CommandButton1.Enabled = False
CommandButton2.Enabled = True
End If
End Sub
Private Sub CommandButton2_Click()
If TextBox1.Text <> "" Then CommandButton1.Enabled = True
TextBox1.Text = ""
TextBox2.Text = ""
CommandButton2.Enabled = False
End Sub