Hello world program
Using the following example we will create our first hello world program. So lets start learning our first simple application. We will show Hello World in a message box. Purpose of this program to understand and getting idea how basic controls works and how we can use simple coding in Visual Basic. We will setup few very basic controls and assign properties like size, caption, and events. then we will write a little piece of code to make it working. Its very simple and basic application program which every programmer creates as his first project to say the word hello.
Actually only learning theories is not enough to stimulate ideas and our programming skills its necessary to do some practicals to have more grip over learnings. So its our first practical which will give us knowledge about controls and fundamentals also will make us little bit confident as we are going to create our very first project in visual basic. Lets do it together.
Step-1 Designing The Interface
Open your visual basic 6 interface and select New EXE project form popup at start up. Now see your toolbox here you will find a control Command Button by double clicking command button a button will appear in center of your form.
Step-2 Assign properties to selected controls
- Click on the form and form properties will appear in properties window.
- In the caption property write My First Visual Basic Project then press enter.
- Now click on the Command1 and select and change the caption property to Show Message and again press enter.
Step-3 Attaching code to your first project
- Double click on command button a popup window will appear with a blinking cursor inside.
- Write the following code here in code window.
- Click run button in the toolbar or also you can press F5 as shortcut key to run your project.
- Now click the command button the message Hello Word will appear in a new dialogue box.
type the code as below:
Step-4 Save your first project
Saving your project is important you can use your project again in future or you
Can use code for another project. Visual basic will save your main project file as .vbp extension. All forms used in projects will be saved as separate files under .frm extension.
- Click on save button in toolbar or save using file menu you can also use shortcut ctrl+s to save.
- A popup window will appear type the name of your project here and proceed by clicking save buton.
You have saved your first project in Visual Basic 6 as you know practice make the man perfect so please repeat your project again and again to understand it well.
Note: We want you to type code by yourself for your practice that’s why we did not pasted code that you can copy or past.