Private Sub Command1_Click()
Dim a1(1 To 5) As Integer, a2(1 To 5) As Integer
Dim i As Integer
For i = 1 To 5
a1(i) = Int(Rnd * 21)
a2(i) = Int(Rnd * 11)
Print a1(i);
Next
For i = 1 To 5
Print a2(i);
Next
Print sum(a1)
Print sum(a2)
End Sub
Private Function sum(a() As Integer) As Integer
Dim i As Integer, sum1 As Integer
For i = 1 To UBound(a)
If a(i) Mod 2 = 0 Then
sum1 = sum1 + a(i)
End If
Next
sum = sum1
End Function