Exercise
Repeat until 0
Objetive
Write a Visual Basic (VB.Net) program to ask the user for a number "x" and display 10*x. It must repeat until the user enters 0 (using "while").
Code
' 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