vb.net

Check whether a number is even or odd in vb.net

In this blog, we will see how to check whether a number is even or odd in vb.net.

Check whether a number is even or odd in vb.net
If a given integer number is Odd or Even. Here if a given number is divisible by 2 with the remainder 0 then the number is an Even number. If the number is not divisible by 2 then that number will be an Odd number.

Check whether a number is even or odd in vb.net
[php]
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks

Namespace ConsoleApp1
Class Program
Private Shared Sub Main(args As String())
Dim number As Integer
Console.Write("Check whether a number is even or odd :" & vbLf)
Console.Write("—————————————")
Console.Write(vbLf & vbLf)
Console.Write("Enter an Integer : ")
number = Convert.ToInt32(Console.ReadLine())
If number Mod 2 = 0 Then
Console.WriteLine("{0} is an even Number." & vbLf, number)
Else
Console.WriteLine("{0} is an odd Number." & vbLf, number)
End If
Console.ReadKey()

End Sub
End Class
End Namespace

[/php]

Result
check-whether-number-even-odd-vb-net

check-whether-number-even-odd-vb-net

Leave a Reply

Your email address will not be published.