Reading Data From Keyboard in VB.NET

In this article You will learn How to Read Data from Keyboard in VB.Net
  • 6277

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

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.