Coder Profile - Show off your skills, get a coder profile.
 
 
 
[VB] Hello World
Programming
DoxCoding.com

Well hello.
I havn't done a Article in ages. And didn't really plan on doing anymore.
So i'm only doing this because am too darn bored,

Anyway, it will only be nice, simple and quick.
It's about Visual Basic 6, Hence the VB in the title.

First we will make a Hello World Message box.
We will make it a critical message box.

So first of all.
Go to Visual Basic 6, You will be congronted with a small dialog box.
There will be many methods of creating a new project, but for this sake, click Standard Exe.

Ok, Now. To the sort of fun part.
Place a Button onto your form,
Double click that button. And you should enter into the code view.

Now for some more fun, and get coding.
Unfortunately, because this is the first program you will do, it wont be very long, and will in a sense, be pointless.
But without further ado, i will get you going.

Within the,

Private Sub Command1_Click()

End Sub

Enter,

MsgBox "Hello, World", vbCritical, "hello"

Now to the explaining part, boooooooooooooring. But you must read this,
The code is a little basic, and self explanitory.
But will clear things out.

MsgBox, This command will start the Message Box, anything following it, in the correct format of course, will be shown somewhere withing that message box.

"Hello, World", this part will be the main part, This will print out Hello World onto the message box.

,vbCritical, This, Yes, When shown will make a little noise . But this will also place a small image, to the left of the Hello World text, showing it is a critical message, If we changed this to ' vbQuestion ' it will place a question mark simble to the left hand side.

Then finally...
"hello", this will be the title bar of the message bar. As you can see, the message bar will say hello.

There are other commands you can add into the message box.
For example you can add in what type of buttons to add.


For the second part of this tutorial.
Create a new project, Standard Exe again.
This time add the following.
1 x Label
1 x Button.
Place them wherever you like.

I will shoot through this, as i have explained above etc. I will still explain though ;)

So, double click the button.
Enter,

Label1.Caption = "Hello, World"

So within that button, your code should now look like this...

Private Sub Command1_Click()
Label1.Caption = "Hello, World"
End Sub


It is wise to tab out you work, in any language. PHP and VB, and C++, whatever.
Just to keep a track of what you are doing.
It also a good idea to comment your work, tell yourself what that part is doing.
Lets add a comment into that code above.

Private Sub Command1_Click()
Label1.Caption = "Hello, World" 'This will change label1 text to Hello, World
End Sub


Now to explain this, very quick, as again, it is self explanitory.
Label1.Caption is the name of the Label. Caption is what is inside.
For example. A Textbox would be.
Text1.Text, as it is text inside. But i will not go into that, you can try it with a textbox too, after you have done it with a label.

So...
Label1 -> Name
.Caption -> Whats inside.

Next
= -> Sets the caption to...

Finally
"Hello World" -> Set text into the caption (label1)


Well. I said it would be simple.
Nice and easy to follow. (I hope).

Well. Laters guys.
Peace

And

Kind regards,
Ant


Posted By otoom
Please login to rate coding articles.

Click here to register a free account with us.
Comments
Please login to post comments.
 
cwbolton     Posted 193 Days Ago
 
 
*coughs* messagebox.show *coughs*

so simple :P
 
otoom     Posted 279 Days Ago
 
 
Becuase i personally think i suck at them, i find it hard to explain things.
 
VBAssassin     Posted 279 Days Ago
 
 
Why didn't you plan on doing anymore articles :-|

Kind regards,
Scott
Page 1 of 1
More Articles By This Author
Quick Threading Tutorial - C++
First look at C
[PHP] How to make a log file.
[VB] Hello World
HTML Cheat Sheet!
[C++] Comments
[C++] Functions
[C++]Taking In User Input,
Your First C++ Program
Recently Posted "Programming" Articles
[PHP] - Lets kill the complex IF
Java: Obtaining User Input - Part 1
Basic PortScanner in VB6.0
N-Queens-Series Part I (Only the fittest survive)
Currying in JavaScript: Fun for the Whole Family!
[PHP] Create A Unique Page Hits Counter
Actionscript Events
Actionscript API
Quick Threading Tutorial - C++
C++ And Me (A Love Story)
Recently Rated "Programming" Articles
[PHP] - Lets kill the complex IF
Java: Obtaining User Input - Part 1
[C++] Templates
Quick Threading Tutorial - C++
Intorduction to memoization.
N-Queens-Series Part I (Only the fittest survive)
[PHP] Create A Unique Page Hits Counter
Currying in JavaScript: Fun for the Whole Family!
Actionscript Events
First look at C
source codes Categories articles
Browse All
Business & E-Commerce (1)
Databases (1)
Design & Creativity (1)
Internet & Web Sites (1)
Life In General (2)
Networking (1)
Operating Systems (4)
Other (2)
Programming (51)
Security (10)
Software Development (5)
Standards (1)
Web Development (15)
search Search Inside
Programming
 
 
Latest News About Coder Profile
Coder Profile Poll
How often do you write code on average per week?

< 5 hours
5 to 20 hours
21 to 30 hours
31 to 40 hours
> 40 hours


please login to cast your vote
and see the results of this poll
Latest Coder Profile Changes
Coder Profile was last updated
5 Days Ago
Official Blog :: Make A Donation :: Credits :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents :: Wallpapers
Version 1.46.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved