Q2 write a window application in VB.NET to find out the even and odd number using user input.

It is said to be a number even when number is divided by 2 and remainder will be zero otherwise it is odd number. The form looks like as follows:


Here textbox accept number and first it will be converted into integer number and assigned to the variable n. the code is as follows:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As Integer
n = Convert.ToInt32(TextBox1.Text)
If n Mod 2 = 0 Then
MessageBox.Show("Number is even", "even or odd")
MessageBox.Show("Number is odd", "even or odd")

End If
End Sub
End Class

In this program if n Mod 2=0 then number is even otherwise number is odd.

MessageBox.Show() is used to show message box. The output is as follows: