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
- 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
- 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.
- 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
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Finally, add a console.readkey under the last line of code you entered because this makes the application available to read without immediately exiting.
- 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
You should read it
- Discovered a new line of malicious Android code that steals user data on the electronic application market
- 5 best command line emulation software for Windows 10
- 2 simple ways to create a Line account on your phone
- How to log out of Line account on Android?
- Some tricks or LINE users should know
- JavaScript code to generate dynamic line graphs/charts
- Just a Line, Google's app that turns the whole world into an exciting 3D drawing board
- How to add or delete friends on LINE?
- Small lines of code change the world
- What is Microsoft Management Console (MMC)? Steps to use Microsoft Management Console
- Quiz: The current technology products are built from how many lines of code?
- JavaScript code to generate error line graph/graph
Maybe you are interested
Acer Launches Its First Handheld Gaming Console That Can Compete With The Best
Why do many people prefer PC gaming over consoles?
Why should you own both a console and a gaming PC?
The new Xbox Discord update allows watching live streams from the console
How to replace console gaming with iPhone
Top best handheld game consoles 2024