## Beginner Tutorial - Hello World

Level:

Visual Basic is a great starter programming language. Not only is it easy to learn, but many business applications use it extensively for their applications. If you are just starting to learn to develop applications - this is a great language to start with.  This tutorial and the many other Visual Basic tutorials at this site will give you a solid foundation in your Visual Basic knowledge.

Lets jump right in with a simple application. When you are done with this Visual Basic tutorial, you should have a complete working application that when you click on the button it will say "Hello, World"

Start Microsoft Visual Basic 6.0 (VB6)

The New Project dialog box will appear. If it doesn't go up to the menu bar and select File -> New Project

In the New Project dialog select Standard EXE, and click the Open Button.

This will bring up your new Project 1 application with Form1 visible.

Already Visual Basic has done a lot for us. As you can see this tutorial isn't very long but already you have a full working application. You can see your new program in action by going up to the menu bar and selecting Run -> Start (Or simply press the F5 key).

You should see the Form1 window appear:

This is a fully functional application. You can move it around, minimize and maximize it, and close it down. For you to do this same thing in C++ - the original language most of Windows was written in you would have written hundreds of lines of code. You area already getting to see some of the extreme power VB gives you. Now lets continue with the tutorial.

Lets make this program say hello!

On the left side of the screen you can see the toolbox (if this doesn't show up go to the top menu bar and select View -> Toolbox). In this toolbox you will see a picture of a button. Double click the button icon and it will create a Command1 CommandButton in the center of your form.

If you run the program now (Press F5) you will see your window now has a button labeled Command1 in the center of it, but if you click the button it doesn't do anything. So lets wire things up so our program will say "Hello, World" when you click the button. Close out of your running program so you are back to the main design environment (pictured above)

Visual Basic allows you to do event driven programming. This is a concept that is very powerful and easy to use. Event driven programming works as follows: Visual Basic has many different events defined that occur when a specified thing happens. We as the programmer can link into these events and write our custom code to do what we want. One very useful event is the Click event. This event occurs any time the user clicks on the specified object. I'm sure the wheels are already turning in your head, if we want to say hello world when someone clicks the button on our form than we should do something in the Click event for the Command1 button. That is exactly what we are going to do.

To write the click event code double click on the Command1 button. This will bring up the code editor and will automatically write the beginning code to handle the click event.

Now any code you put between the Private Sub ... and the End Sub statements will be executed when the user clicks the command button. To demonstrate this we will have a message box appear saying hello world. So add this line of code:

Private Sub Command1_Click()
MsgBox "Hello, World!"
End Sub


MsgBox is a built in Visual Basic function that causes a message box to be displayed to the user. The first parameter this function takes is the text string you wish to have displayed. We choose the text string "Hello, World!". MsgBox also takes other parameters to specify things such as what buttons to display and what caption to use, but these will be discussed later. For now lets see how this works. Run your newly created Visual Basic hello world program (Press F5). Once the program is running click the Command1 button, you should see a message box saying Hello, World! appear.

Congragulations! You have written a complete working Visual Basic program using this Hello, World tutorial. Read some of our other VB6 tutorials to learn how powerful this language really is.

If you enjoyed this post, subscribe for updates (it's free)

very nice

Nice demo.

### (VB) guidelines

the tech... now is so hitech
,,,,,,,,,, we make ev'ryhing in a visul basic
what ever we want to but if it's related on the program

I need it now very badly for my project that will be passed tomorrow morning!

### Can you help me sir with this vb6.0 tutorial

Can you help me sir in making a log in and logout program

### Good Job

Wow...this was VERY VERY helpful... thank you.

### Thanks

Nobody's programmers begin the program not try writes "Hello World" :D

### WTF

What are you trying to say?

### Good

Simple to learn. Thanks

### Excellent!

Wow! You really make my start and I am very thanksfull> Your explanation is very helpful indeed..

### Thanks

This Was My First VB 6 project that was very easy and useful thanks :))

### Do you think it's bad if my

Do you think it's bad if my first program using vb6 as a very advanced program?

### super easy yet super

it triggers my mind about vb..

thanks a lot

### Hello World ...easy peasy

Hello World ...easy peasy

### Private Sub

Private Sub Command1_Click()
msgBox "Hello, World!"
End Sub

### thanks! helped me make

thanks! helped me make sense of VB

### so easy code..! but that's

so easy code..! but that's so useful.

not good

### I don't have any problems

I don't have any problems with this other than the spelling and grammar. Sometimes these tutorials make no sense with text like this - You area already getting to see some of the extreme power VB gives you. Not that this sentence has any significance.

### Classically good example, but a mark missed

The time honored "Hello World" is a good example to have used for the beginner. The writing is also easy to understand. However, I take a different point of view with a block like

"This is a fully functional application. You can move it around, minimize and maximize it, and close it down. For you to do this same thing in C++ - the original language most of Windows was written in you would have written hundreds of lines of code. You area already getting to see some of the extreme power VB gives you."

I think it slightly misses the mark. The tutorial author seems to somehow forget that there is VC++ (Visual C++), that similar behind-the-scenes technology that allows you to easily crank out standard Windows Application in VB also allows you to do same in VC++. The point should not be whether Windows was written in C++ or Basic, or Assembler for that matter, the point should be that the complexities that make up the framework of a Windows application --- Window, Frame, Button & other widgets creation, their rendering, Events, Listeners/Callbacks instantiation and setup within a Main Loop --- all of these are intelligently taken care of by the Visual technology: Visual Basic, Visual C++ or other competing Visual programming technologies.

If the point was to make the learner appreciate the simplicity enabled by, in this case, the Visual Basic technology, I would have expected the tutorial author to show all the source code that actually make up the simple "Hello World" application. Of course a link to it would suffice; but the author could then have discussed that Visual Basic (like Visual C++) always takes care of them so that the programmer can concentrate more on the design and flow.

### Thanks for Demo!!

Thanks a lot!! But I need some big Demo Example....

### Very Simple

This example is very simple and it should be a litle bigger. For example specifying a title for the message box.

### Coming from a C++

Coming from a C++ background, I find VB to be so much simpler and less stressful.

### Nc.... It help those

Nc....
It help those beginner like me to easily understand what is the function of that code...

hope you make more of them hehhhhe...

and represent it the way you represent "hellow World"

easy to understand....

### i wish i could help u

ok help me people i am stuck on commanding a command button in vb6 help in the fnd if etc...

### Untitled

it's great to see that boring people do boring jobs, like yourself(programmers). keep the internet going ;)

Dwarf Shortage

### Untitled

it's great to see that boring people do boring jobs, like yourself(programmers). keep the internet going ;)

### This doesn't work with

This doesn't work with Visual Basic 10. It's quite annoying.

### You should look into the

You should look into the vb.net stuff for that. vb6 is not code compatible to vb10.

### Need more conformation

I need a code for saving the files created in the VB with own file format.
Can anyone help me with this.

### ...Look Down...

hey i suck when it comes to vb6 coding but i have relaced a program to change the start button text For Windows XP AND XP ONLY!!!!!!!!!!!!!!!!
Good luck
Get It Free @
startbuttonchangerxp.webs.com

thats nice

### code writing

good day sir, in case like these- private sub form (). what is suppose to be in the bracket. is it write up like this or not. e.g (ByVal Sender As System.Object,_ ByVal e As System.EventArgs).
please help because i have written some program but that is where is holding it from running.
THANKS

### I can help if it is needed!

Hello Everyone!

I have taken Computer Programming, Software Applications, Desktop Publishing, Computer Design and more. If anyone needs help writing code for a program please email me at drekryan@yahoo.com and explain what you need with a much information as possible!

Good Luck! :)

### visual basic

hi sir gud day can you help us about the coding simple login and logout system. thank you

### 5 star

exactly for the begginer like me ^_^

### Hello, World!

Hi,

Learning is made very simple by well written in simple step by step instructions.
Thanks a lot.

subburaj ramiah

### thank you for helping me in

thank you for helping me in my exam...

### Thank YOU

this is awesome for beginners. thanks

### hi

its help a lot to the studint like me...thank you so much...

### awesome

very good article, easy to read and learn, thank you x100!

### Wow!

I'm Jonalyn

Wow! So thankful that you have tutorials like this...
It's a big help for beginners and amateurs who can't understand VB that much.......
A many thanks to you, and for all the people who helped put it all together......mwahh

Best Wishes!!
Arigatou Gozaimasou!

### Thanks a lot

Thanks a lot for providing such a great resource...Now I am trying to learn VB 6 ..and I will follow your website....I am really thankful to you ...

### i want the program visual

i want the program visual basic vb now

### Texts and labels

I've tried most parts of VB, and they are very interesting, but is there any way the background of the text and the label be made transparent.
Thank you.

### Books traking system

What is required to start my application that will store books information in the library including books location in the shelves, keep track of borrower information.
plz i would like your contribution on that.

### thanks

wow this program is realy interesting. hw i wish u cud send more program tutorials or beta still tutorials on hw these visual basic code works.

### msgbox

wow...msgbox it's easy as our teacher teach us about that...!!!
i love it...that's easy!!!

### Visual basics

dfg great it is really a lovely programme.I enjoyed it.give some more programme that will build the knowledge in programming.

### Thnx much

Im the beginner \in programming and this is ma last year to complete 3yrs in computer engineering
I suppose to conduct a project so as to graduate
it was very difficult for me to conduct it
bt im now prepare ma self to create a program that will store information for every students in our college

now im very happy to see your tutorial like this and im sure ma problem will be solved

plz any one can help me on that project im going to conduct?
by bunally@yahoo.com

### I can be your partner in that...

that kind of work is difficult but it would be easy if there would be TWO brains that will function than one...you can ask me if y0u want...

### vb6 user details capture screen code examples

can someone help and send me some codes on programs like, LOGON FORM/SCREEN, CUSTOMER DETAILS CAPTURE SCREEN/FORM and other codes for capturing details and store them in a database

### GREAT MAKE MORE!!!

GREAT MAKE MORE!!!

### Great

Simple. Facile. Comprehensive. Scores of thanks. But little by little the cotton threads become cloth: so please more & more.

### very nice tutorial.. i want

very nice tutorial.. i want some more!!!
how bout those that uses equations!!!

### thanx

thanx really... ive been looking for some friendly tutorial, and finally found it

### Thanks Alot! it was very

Thanks Alot! it was very helpful. and is helping me alot already

### First timer...

Tis really helps...very straight forward...thnx...

Good Tutorial

### wow..........kjn kjnc kjncv

wow..........kjn kjnc kjncv

### So brilliant!!!

It really helps me a lot.....

### please send me other coding tutorials I really liked it.

Thanx for your brief and undustandable explanation of codes. Please add me as many coding tutorials as you can. I wanna be an expert in programming.

### visual basic6.0 program

please send me other coding related to visual basic6.0

### Easy

This was easy. Love it ^^

### this was ok love basil mwah

this was ok love basil mwah xoxo

### jm

wow! this is great... very well explained! love it dude.. thanx a lot!!!

### Great

Very simple, clear and effective. Good job!

### Nice

Thanks dude. This thing really helped me..and now my family is impressed with me. But I couldn't have done it without you. Thanks and Continue making tutorials like this. People (including me) love 'em!

### Clean and includes source.

Clean and includes source. A+ =)

### thanx

this is the first tutorial i see that works..thanx men..

Im just a Newbe..and a wanna be programer..till college.

### tnx

tnx for this simple tutorial......... -erg23

### THANX

HEY THANX MAN.DIS TUTORIAL IS REALLY HELPFUL ..WELL HOPE I WILL BE A MASTER SOMEDAY.

### THANX

HEY THANX MAN.DIS TUTORIAL IS REALLY HELPFUL ..WELL HOPE I WILL BE A MASTER SOMEDAY.

### Awesome.

I really appreciate the explanation of even the "MsgBox" feature and how you go in depth on what it does. Most tutorials just give you the code and say "awesome your first project is done." In fact you EXPLAIN that feature which is REALLY needed. Thank you.

### Cheers!

Thanks that just got me started!!! MORE MORE!

### Very Useful

This Visual Basic tutorial was very helpfull in helping me know how to just make something simple. I would like more tutorials like this that are geared towards the beginner.

### nice work

I like the way the lessons are presented...

### COMPLETE PACAKAGE

let me say u thanks..coz i have search the whole worls fo visual basic tutorial........but do trust me it the best i have found ever.just start from the 0 level to the utmost level.thank u......

### THIS WAS THE THING I NEEDED

THIS WAS EXACTLEY WHAT I NEEDED TO UNDERSTAND THE PROGRAM. MANY MANY THANKS TO YOU, DEAR WRITER OF TUTORIAL!

### really nice

thanks a million...real good way to learn vb....cheers