Ejercicio
Repetir hasta 0
Objetivo
Cree un programa en Visual Basic para pedir al usuario un número "x" y mostrar 10*x. Debe repetirse hasta que el usuario ingrese 0 (usando "while").
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()
' Declare a variable to store the number entered by the user
Dim x As Integer
' Start a while loop that continues as long as x is not 0
While True
' Ask the user to input a number
Console.Write("Enter a number (0 to stop): ")
' Read the user's input and convert it to an integer
x = Convert.ToInt32(Console.ReadLine())
' If the user enters 0, break the loop and stop the program
If x = 0 Then
Exit While
End If
' Display the result of 10 * x
Console.WriteLine("10 * " & x & " = " & (10 * x))
End While
End Sub
End Class