Home >>VB.Net Programs >VB.Net program to check the given number is POSITIVE or NEGATIVE

VB.Net program to check the given number is POSITIVE or NEGATIVE

Write a VB.Net program to check the given number is POSITIVE or NEGATIVE using conditional operator

We will read the integer number here and check if the given number is POSITIVE or NEGATIVE, and then print the appropriate message on the screen of the console.

Program :

Below is the source code to check whether the given number is POSITIVE or NEGATIVE. The program given is compiled and successfully executed.

Example


	Module Module1
 
    Sub Main()

        Dim num As Integer = 0
        Dim result As String

        Console.Write("Enter Your number : ")
        num = Integer.Parse(Console.ReadLine())

        result = If((num < 0), "Given Number is Negative", "Given Number is Positive")
        Console.WriteLine(result)

        Console.ReadLine()
    End Sub
End Module
	
Output:
Enter Your number : -3
Given Number is Negative

Explanation:

We created a Module1 module in the program above that contains the Main() method. We created a local variable num and output in the Main() method. After that, we read the num value.

result = If((num < 0), "Given Number is Negative", "Given Number is Positive")

We checked the POSITIVE or NEGATIVE number in the code above, after printing the required message on the console screen.


No Sidebar ads