ARTICLE

Reading Data From Keyboard in VB.NET

Posted by Rohatash Kumar Articles | Visual Basic 2010 September 16, 2010
Tags: VB.NET
In this article You will learn How to Read Data from Keyboard in VB.Net
 
Reader Level:

HTML clipboard

In This article You will learn How can read a data from keyboard in VB.NET.

Reading Data From Keyboard:

  1. Read the data using ReadLine() method of Console Class.                                     
  2. returned is of string type 
  3. We need to convert data from string to other value types.
  4. Use Parse() method from the data type to convert data from string to value types.

For example:

Get name and basic of an employee and print the DA of an employee as 92%.

Module Program

 

    Sub Main(ByVal args As String())

        Console.Write("Name : ")

        Dim name As String = Console.ReadLine()                                'ReadLine() method used to Read the data

        Console.Write("Basic : ")

        Dim basic As Integer = Integer.Parse(Console.ReadLine())           

                                                                 'parse method used to convert the data string to value type

             'Console.WriteLine("Da of " + name + " is " + basic * 0.92);

        Console.WriteLine("DA of {0} is {1}", name, basic * 0.92)

        'Console.WriteLine("Hell to all");

        'Console.ReadKey();

    End Sub

End Module

OUTPUT for the above code:

parse.gif

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Become a Sponsor