Discovering Visual Basic .NET, Page 2
Getting Started with Programming
If you have very little or no computer programming experience, review the next couple of sections. They define some terms and describe some basic concepts that you need to know to get started. If you've done some programming, feel free to skim or skip these sections.
What is a programming language?
A computer programming language is a lot like a human language. As with a human language, each computer language has a vocabulary of words. Likewise, each language has syntax rules for putting the words together in meaningful ways.
Also, human language is designed for two-way communication, whereas programming is a one-way street: You tell the computer exactly what it's supposed to do and how it should respond to every situation. Instead of a conversation, it's more like a recipe or a to-do list. The computer then simply follows your instructions. The computer can't argue with you. (However, when it throws error messages your way, you may feel like it's being argumentative!)
That's why the words in a computer language's vocabulary are often called commands or statements. When you put a series of commands together, the result is referred to as source code, or simply code. When you bring all the source code together, you have a computer program or application.
Compiling and running
After you create an application, you still have one problem: The computer can't read the source code directly. The computer really only understands binary numbers—ones and zeros. A series of commands given to the computer in binary form is called machine code. After you finish writing and debugging your source code, you run a piece of software called a compiler, which translates your source code into machine code.
You only need to compile your program once. After that, you run or execute the program, causing the computer to carry out your commands. You can run the compiled code again and again. You don't need to compile it again unless you change the source code. The machine code usually takes the form of an .EXE file, or executable. This file is distributed to those who need to use the application, people who are fondly referred to as users or, in the case of Web sites, visitors.
Note: If you already have some experience with .NET and how it works (or if you've worked with Java) you may know that the compiling and execution process is quite a bit more complicated than is explained here. But when you're getting started, this is the all the detail you need to know. There'll be plenty of time for diving into the deep end once you get Visual Basic .NET under your belt!
Your First .NET Program
There's a long tradition in computer programming tutorials of creating a first application that does nothing more than display "Hello, World". The idea is that, if you can get to that point, you have everything set up and working well enough to begin experimenting and learning. You are ready for your "Hello, World".
Begin by creating a folder on your hard drive under My Documents. Name the folder HelloWorld.
Now, open Notepad. Type in the following text:
Imports System Module HelloWorld Public Sub Main() Console.WriteLine("Hello, World!") End Sub End Module
This is about the simplest program you can write in Visual Basic .NET—just the essential elements. I'll go over each of these elements in the next article. For now, I want to get you used to the process of writing, compiling, and running a program.
Save your Notepad file. Save it in the HelloWorld folder you created and name it "HelloWorld.vb".
Important Note: Be sure to actually put quotation marks around the file name when you type it in Notepad's Save As dialog. This informs Notepad not to add a .txt extension to your file. Check to be sure the file is named correctly after you save it. If there is a .txt extension on your file, rename the file so that it is simply HelloWorld.vb.
Leave Notepad open, but minimize it for now. Double-click on the shortcut you created on your desktop after you installed the .NET Framework (earlier in this article). This opens a black window with a text interface (see Figure 2).
Figure 2. The .NET Framework Command Prompt window.
Page 2 of 3