VB.Net Programming Console Application Walkthrough Example : Input Output
Narrative Memory Screen Code The first line of the program indicates the main( ) procedure. Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age.........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", Interest) Console.ReadKey() End Sub
Narrative Memory Screen Code Name Age Gender Balance Interest 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. Name Age Gender Balance Interest Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age.........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", Interest) Console.ReadKey() End Sub
Narrative Memory Screen Code Enter Name…….: Name Age Balance Interest 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age.........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….: Name Age Balance Interest Gender
Narrative Memory Screen Code Name Age Gender Balance Interest Jim This next line reads the line typed by the program user and stores it in the named memory location Name. Name Age Gender Balance Interest Jim Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age.........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", Interest) Console.ReadKey() End Sub Enter Name…….:Jim
Narrative Memory Screen Code This line writes to the console screen. The words in quotes appear on the screen. Name Age Gender Balance Interest Jim Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age.........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", Interest) Console.ReadKey() End Sub Enter Name…….:Jim Enter Age………:
Narrative Memory Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age.........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", Interest) Console.ReadKey() End Sub Code Narrative Memory Screen Enter Name…….:Jim Enter Age………:23 Name Age Balance Interest Jim 23 Gender
Narrative Memory Screen Code This line writes to the console screen. The words in quotes appear on the screen. Name Age Gender Balance Interest Jim 23 Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age.........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", Interest) Console.ReadKey() End Sub Enter Name…….:Jim Enter Age………:23 Gender.…………:
Narrative Memory Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age.........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", 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
Narrative Memory Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age.........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", 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
Narrative Memory Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age.........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", 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
Narrative Memory Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age...........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", 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
Narrative Memory Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age...........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", 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
Narrative Memory Screen Code This final line holds the display until the program user presses a key. And this program ends. Name Age Gender Balance Interest Jim 23 M 100.00 10.00 Screen Code 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("Enter Name :") Name = Console.ReadLine() Console.Write("Enter Age :") Age = Console.ReadLine() Console.Write("Enter Gender :") Gender = Console.ReadLine() Console.Write("Enter Balance :") Balance = Console.ReadLine() 'Process Interest = Balance * 10 / 100 'Output Console.WriteLine("-----------------") Console.WriteLine("Name........:{0}", Name) Console.WriteLine("Age...........:{0}", Age) Console.WriteLine("Gender......:{0}", Gender) Console.WriteLine("Balance.....:{0}", Balance) Console.WriteLine("10% Interest is :{0:f2}", Interest) Console.ReadKey() End Sub 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