How to Say 'Hello' to a Custom Name in a Console Application in VB.Net

When you say hello in a Console Application on Visual Basic.NET, you might want the user to enter a name for you to use for the basic application. This tutorial teaches you all of that. Navigate to the [http://www.visualstudio.com/en-us/...
Method 1 of 2:

Downloading and Installing

  1. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 1How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 1
    Navigate to the Visual Express 2010 Download Page and select the Visual Basic section. Make sure that you are NOT on any other sections as this renders this tutorial useless
  2. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 2How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 2
    Download the file and complete the installation process. If there are any hiccups (which are very rare) you should be displayed with an error message explaining what you should do.
  3. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 3How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 3
    Once the installation is complete, run the program. You should be given a pop-up message requiring a product code. Click the Obtain a registration key online button and then fill out the product code form.
Method 2 of 2:

Coding The Application

  1. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 4How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 4
    Open up VB.Net and you should arrive on the home page. Click on "New Project" or if you're homepage is not being displayed for some reason, click on the file tab at the top and then click on New Project.
  2. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 5How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 5
    Make sure that Console Application is highlighted and then give a name for your project. The name part is only important in case you want to look for this project again. Then you have something to stand out in the file explorer.
  3. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 6How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 6
    Now that you are in the code, select the line just under Sub Main() and write dim' . You are now declaring something and this plays a key role in getting the user's name and using it in a sentence.
  4. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 7How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 7
    After the dim write name and As String. The "name" part can be anything you would like but it would just be a bit clearer. However, the "As String" part MUST be there as you need to make sure that the computer reads words, not numbers or other things.
  5. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 8How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 8
    Now, you are going to write two lines of code. The first one, Console.Writeline("What is your name?") asks for your name. The Console part is telling the computer to do something whilst the Writeline is an extension telling it to write something onto the application. The text inside the speech marks inside the brackets is what's going to appear on the screen.
  6. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 9How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 9
    The second line of code will say name = console.readline() . Again, the console part is telling it's for the computer, the readline tells the computer to store the answer from the first line of text into the name that we declared earlier.
  7. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 10How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 10
    Then you will put another Console.Writeline but this time you will add Console.Writeline("Hi {0}", name). The {0} represents the first variable being used because in this type of situation, you will ALWAYS start with a 0. The ,name part brings out the custom name that is stored out through the {0} part.
  8. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 11How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 11
    Finally, add a console.readkey under the last line of code you entered because this makes the application available to read without immediately exiting.
  9. How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 12How to Say 'Hello' to a Custom Name in a Console Application in VB.Net Picture 12
    Run the application and then you should be asked for your name and then the application should say hi to you! If that happens then you have coded the application correctly.
4 ★ | 1 Vote