Site hosted by Angelfire.com: Build your free website today!

VB Tutorial Part II

NEW: LAN and LAN PARTY INFO
Main
   Home
   Uploading
   Links
Download
   Games
Arcade
   K.M.'s Games
   Java on the Brain
   Javanoid
   NineBall
Discussion
   Message Board
Archive
   News
Programming
   Download Code
   
VB Tutorial

     Making a Hello World App

     So you think your ready to make a real application?  Well we shall see.  Now, if the you still have Visual Basic open, then find the TextBox object on the Tool Bar, and double click on it.  Wa la!  It is now on your form.  You could have just clicked on it and then "draw" it on the form, but this is easier.
     Go to the Properties Menu and find the "(Name)" property.  Change it from "Text1" (never put the quotes I put around words unless I have it like this ""Hello"", with double quotes, the quotes are only to separate the word or action from the rest of the sentence) to "txtHello".
     Then scroll down the Properties Menu and find the property called "Text".  Change it from "Text1" to nothing.  Delete it, because we don't want any text in it right now.  One more thing to change.  Find the Height property,  Change it from "495" to "375".  Now its not so tall and looks like an everyday Windows TextBox.
     Now we need to add a CommandButton.  This time, click on the CommandButton tool in the tool bar only once.  Now, go to some part of the form (where you would like the button) and "draw" the CommandButton, by clicking and dragging it, to a size that you like.
     Now follow the "Change the Properties" chart below for your new CommandButton:

     
Property        From                    To
     (Name)           Command1           cmdHello
     Caption           Command1           Hello World!
     
     Now that you have done that, double click on the "Hello World!" button.
     You have now began the actual programming part. 
     You may see some thing like this:

     
Private Sub cmdHello_Click()

     
End Sub
     
     Now, in between the "Private Sub cmdHello_Click()" and "End Sub" is where the code for the "cmdHello" CommandButton goes.  To translate the "Private Sub cmdHello_Click()" in english would be something like:  "When you Click on the cmdHello object, do the code below until you reach the End Sub".
     Enter this in between the "Private Sub cmdHello_Click()"  and "End Sub":

     txtHello.Text = "Hello World"

     Note: This time you would put the quotes in.
     To translate this code means: "The text in the object txtHello is now "Hello World".

Test Your Program

     That's it.  You have made a program, now its time to see if it works.  Close the "Code" box.  Now up, up above, find a button that looks like the button to the left.
     Click on it and your program begins to run.  Click the "Hello World!" button.  And there you have it, the text in the TextBox says "Hello World".
     The stop the program, click on the "Stop" button, just two buttons to the right of the "Play" button.