ARTICLE

How to read user input using While loop in Vb.Net

Posted by Manish Tewatia Articles | Visual Basic Language July 23, 2010
In this article I describe the process of reading user input by using while loop
 
Reader Level:

As we have now written some text to forcing the user to inter values to move on the next step of the program this user inputs stored virtually in the program and produced the desired output. Now for read this user inputs we need some specific code sniped as like While loop statement, in this statement the task will repeated until the given condition does not reached.

Syntax

While [condition][loop body]
End WhileWhile ..End while loop execute the body(the source code within while and end while statement) until it meets the specified condition.

Examples

    Module Module1
        Sub Main()
            Console.WriteLine("Please enter 'e' to exit")
            Dim Input As String = Console.ReadLine()
            While (Input <> "e")
                Console.WriteLine("Typed value is: " & Input)
                Console.WriteLine("Please enter 'e' to exit")
                Input =
Console.ReadLine()
            End While
            Console.WriteLine("press enter to exit.")
            Console.ReadLine()
        End Sub
    End
Module

OUTPUT

3.gif

CONCLUSION

This article helps you to understand that how you can read the user input by using While loop in VB.NET.

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor