Visual Basic: Input Operators and Variables

Posted: January 31st, 2012 | Author: | Filed under: Visual Basic Tutorial (Series) | No Comments »

Continuing on from the Hello World program let us personalise the program by asking the name of the user who is using the console.

Program

  • Open A New Project and save it as “Hello YOU”.
  • Type in the following code into your text editor

Remember between the Sub Main() and End Sub

Console.Writeline(“Hello, What is your name”)
Dim username As String
username = Console.Readline
Console.Writeline(“Hello ” + username)
Console.Readline()

Press F5 and POW! Do what you’ve just programmed the program to do! Type in your name.

 

 

 

Input Operators Summary

Purpose: To Read text entered by the user
Code: Console.Readline() alternatively
Console.Read()

Example: username = console.readline()

You know we’re gonna have some fun with this!! You just need to learn a little bit more and POW! You’ll have learn’t something, but not before I explain what the dim thing was all about!


Input Operators Summary
Purpose: To read text entered by the user
Code: Console.Readline() or
Console.Read()
Example Username = Console.Readline()

Variables Summary

 Data Entered by the user need to be stored. Computer programs use variables  to store data. A variable has a name and data type. Variables need to be declared.

Dim username As String

Next Tutorial: Visual Basic Data Types

Visual Basic Tutor



Leave a Reply