Ejercicio
Positivo y negativo
Objetivo
Escriba un programa en Visual Basic para obtener un número y responda si es positivo o negativo.
Código
' Import the System namespace to use Console class
Imports System
Public Class Program
' Main subroutine, entry point of the program
Public Shared Sub Main()
' Ask the user to input a number
Console.Write("Enter a number: ")
' Read the user's input and convert it to a double
Dim number As Double = Convert.ToDouble(Console.ReadLine())
' Check if the number is positive, negative, or zero
If number > 0 Then
' Display that the number is positive
Console.WriteLine("The number is positive.")
ElseIf number < 0 Then
' Display that the number is negative
Console.WriteLine("The number is negative.")
Else
' Display that the number is zero
Console.WriteLine("The number is zero.")
End If
End Sub
End Class