17. Write a VB program to find even and odd numbers from an array.


Private Sub cmdClear_Click()
Form1.Cls
End Sub

Private Sub cmdDisplay_Click()
Dim a() As Integer
n = InputBox(“How many elements do u want to enter”)
ReDim a(n)
Print “Array is : ”
For i = 0 To n – 1
a(i) = Val(InputBox(“Enter the Elements”))
Print a(i)
Next
Print “Even Numbers are : ”
For i = 0 To n – 1
If a(i) Mod 2 = 0 Then
Print a(i)
End If
Next

Print “Odd Numbers are : ”
For i = 0 To n – 1
If a(i) Mod 2 <> 0 Then
Print a(i)
End If
Next
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s