Dim a(1 To 10) As Integer
Private Sub Command1_Click()
Dim i As Integer
Text1.Text = ""
For i = 1 To 10
If odd(a(i)) Then
Text1.Text = Text1.Text & "a(" & i & ")= " & a(i) & " 是奇数" & vbCrLf
Else
Text1.Text = Text1.Text & "a(" & i & ")= " & a(i) & " 是偶数" & vbCrLf
End If
Next
End Sub
Private Sub Form_Load()
Dim i As Integer
Randomize
For i = 1 To 10
a(i) = Int((50 - 20 + 1) * Rnd + 20)
Next
End Sub
Private Function odd(ByVal n As Integer) As Boolean
If n Mod 2 <> 0 Then odd = True
End Function