Exercise
While + Counter
Objetive
Write a Visual Basic (VB.Net) program to display the numbers 1 to 10 on the screen 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 counter variable starting from 1
Dim counter As Integer = 1
' Start a while loop that will run as long as the counter is less than or equal to 10
While counter <= 10
' Display the current value of counter
Console.WriteLine(counter)
' Increment the counter by 1 after each iteration
counter += 1
End While
End Sub
End Class