To start writing your first program in Visual Basic (VB), first open the Visual Basic 2010 IDE. Then follow the steps to start writing the code;
- Click on “New Project”; It will open the new project window
- Click on the “Console Application”; we can also use the “windows form application” but for a beginner to VB it is necessary to get familiar with the syntax used in VB first.
- Type a proper name for your project at the bottom of the project window
- Click “OK” and it will load your project
- Start coding
See Also: [button link=”http://codejow.com/starting-visual-basic-programming-language/” size=”default” icon=”fa-star” side=”left” target=”” color=”ac75b7″ textcolor=”ffffff”]Setting Up Visual Basic 2010[/button]
Below you can see the project “Hello CodeJow Viewers” which I have loaded. The project has started with module and has ended with module. Do remember that every program in Visual Basic starts and ends with the type of it. For example; you can create a class in your program by the name of “ABC”, you should end it with “end class” always. Another example of this rule is the “sub” above.
Every program you type in Visual Basic must have a main sub or sub main (). It is the start of the program. If a program does not have a main sub, it will not run.
So let’s type our first program in Visual Basic 2010
Follow the steps:
All the lines of codes that we will be typing must be inside the main sub for now.
- Type – Console.WriteLine (“ ”)
Between the 2 quotation marks you can type your message to be displayed on the screen. We have typed “Hello CodeJow Viewers!”.
What this line does is it writes the message you type between the quotation marks on the console.
- Type – Console.ReadLine ( )
You always put the curly braces in this case empty. We simply call it empty arguments.
This line only keeps the console so that the user may read his message.
In case you do not write this line of code, the message will be written on the console. Once you run your program, it will quickly display the message and close the window. It will not wait for the user to read the message.
- Once you are finished with writing the lines of code, you can simply press the run button. It will compile the code and run your program on the CMD windows.
Between the 2 quotation marks, you can write any message of yours to be displayed on the CMD windows.
Congratulations! You have just typed your very first program in Visual Basic 2010.
Stay tunned for further tutorials and articles on Visual Basic Programming Language.