How to use while to read user input until user decides to exit in VB.NET

1 Answer

0 votes
Imports System

Public Class Program
	Public Shared Sub Main()
		Console.WriteLine("Enter 'q' to quit")
        Dim input As String = Console.ReadLine()

        While (input <> "q")
            Console.WriteLine("You typed: " & input)
            Console.WriteLine("Enter 'q' to quit")
            input = Console.ReadLine()
        End While
		
		Console.WriteLine("END")
    End Sub
End Class





' run:
'
' Enter 'q' to quit
' C#
' You typed: C#
' Enter 'q' to quit
' VB
' You typed: VB
' Enter 'q' to quit
' Java
' You typed: Java
' Enter 'q' to quit
' q
' END
'

 



answered Aug 3, 2022 by avibootz

Related questions

1 answer 143 views
1 answer 187 views
187 views asked Apr 21, 2017 by avibootz
1 answer 189 views
1 answer 169 views
1 answer 186 views
...