Wlkthru vb netconsole-inputoutput

513 views
480 views

Published on

This short presentation shows you the steps involved in creating a simple console application in VB.NET. Microsoft Visual Studio VB.NET Express 2010 was used.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
513
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
36
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Wlkthru vb netconsole-inputoutput

  1. 1. VB.Net Programming Console Application <ul><li>Walkthrough Example: </li></ul><ul><li>Input Output </li></ul>
  2. 2. The first line of the program indicates the main( ) procedure. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age.........:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen
  3. 3. These lines create named memory locations to store the data entered by the program user. Name is string to store characters Age is integer to store whole numbers Gender is char to store a single character Balance & Interest are decimal to store numbers with digits after the point. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age.........:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Name Age Balance Interest Gender
  4. 4. This line writes to the console screen. The words in quotes appear on the screen. Write will display the contents of the quotes and stay on the same line. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age.........:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….: Name Age Balance Interest Gender
  5. 5. This next line reads the line typed by the program user and stores it in the named memory location Name. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age.........:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….:Jim Name Age Balance Interest Jim Gender
  6. 6. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age.........:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub This line writes to the console screen. The words in quotes appear on the screen . Code Narrative Memory Screen Enter Name…….:Jim Enter Age………: Name Age Balance Interest Jim Gender
  7. 7. This next line reads the line typed by the program user and stores it in the named memory location Age. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age.........:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….:Jim Enter Age………:23 Name Age Balance Interest Jim 23 Gender
  8. 8. This line writes to the console screen. The words in quotes appear on the screen. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age.........:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….:Jim Enter Age………:23 Gender.…………: Name Age Balance Interest Jim 23 Gender
  9. 9. This next line reads the line typed by the program user and stores it in the named memory location Gender. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age.........:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….:Jim Enter Age………:23 Gender.…………:M Name Age Balance Interest Jim 23 Gender M
  10. 10. This line writes to the console screen. The words in quotes appear on the screen. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age.........:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….:Jim Enter Age………:23 Gender.…………:M Enter Balance…..: Name Age Balance Interest Jim 23 Gender M
  11. 11. This next line reads the line typed by the program user and stores it in the named memory location Balance. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age.........:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….:Jim Enter Age………:23 Gender.…………:M Enter Balance…..:100 Name Age Balance Interest Jim 23 100.00 Gender M
  12. 12. This next line uses the contents of Balance to calculate 10% of its value and places the answer into the location Interest . Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age....... .. ..:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….:Jim Enter Age………:23 Gender.…………:M Enter Balance…..:100 Name Age Balance Interest Jim 23 100.00 10.00 Gender M
  13. 13. These next lines Write the contents of the variables to the console screen. Note the use of {0} which represents the position of the named variable between the quotes. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age....... .. ..:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….:Jim Enter Age………:23 Enter Gender. .…:M Enter Balance…..:100 ------------------------------- Name…………:Jim Age……………:23 Gender………..:M Balance………..:100 10% Interest is..:10.00 Name Age Balance Interest Jim 23 100.00 10.00 Gender M
  14. 14. This final line holds the display until the program user presses a key. And this program ends. Sub Main() Dim Name As String Dim Age As Integer Dim Gender As Char Dim Balance As Decimal Dim Interest As Decimal 'input data Console.Write(&quot;Enter Name :&quot;) Name = Console.ReadLine() Console.Write(&quot;Enter Age :&quot;) Age = Console.ReadLine() Console.Write(&quot;Enter Gender :&quot;) Gender = Console.ReadLine() Console.Write(&quot;Enter Balance :&quot;) Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine(&quot;-----------------&quot;) Console.WriteLine(&quot;Name........:{0}&quot;, Name) Console.WriteLine(&quot;Age....... .. ..:{0}&quot;, Age) Console.WriteLine(&quot;Gender......:{0}&quot;, Gender) Console.WriteLine(&quot;Balance.....:{0}&quot;, Balance) Console.WriteLine(&quot;10% Interest is :{0:f2}&quot;, Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….:Jim Enter Age………:23 Enter Gender. .…:M Enter Balance…..:100 ------------------------------- Name…………:Jim Age……………:23 Gender………..:M Balance………..:100 10% Interest is..:10.00 Name Age Balance Interest Jim 23 100.00 10.00 Gender M

×