Bidvertiser Advertisement

Jumat, 13 Agustus 2010

Learning Visual Basic 2008 (Really Basic)












If you are really new in Visual Basic and you want to learn about it more, lets begin slowly. Lets make a simple user interface or in programming we called "Form" . In menu file, choose new project and then in new dialog box, choose Windows Form Application. 

 You can give a special name if you want it. Click "OK" to continue.












Your monitor will be like the picture below :















There are 5 main part windows in that picture, consists of: Toolbox windows, Output Windows, Properties Windows, Project Explorer Windows, and The Design Windows. 
Toolbox Windows is used to choose elements that we want to give to the form. The Output Windows display the error list, warning, and messages when the program is ran. Properties Windows is used to set all of the properties in Form, include the elements (text box, label, combo box, option button, button, and many others). And the last is Design Windows. Here you can write your source code, set up the form (position, color, font) and see the result.

For a simple begining, lets drag and drop some elements from Toolbox windows : Button , Text Box, and Label, just 1 for each element.
Make your form like this picture : 













To change the Form Title from "Form1" to "Practice1" , just enter to the Properties Windows and then choose Form1 Properties. Find "Text" Properties, and then change it into another word you want to.

Double click Button1 until you a source code windows displayed like this picture: 







The scenario is we can set the Text in Label1 based on what we type in TextBox1 when we click Button1. So we have to make sure that we have type a word in TextBox1 before we click Button1.

Type it into your source code windows:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.Label1.Text = Me.TextBox1.Text

End Sub

Me. -> is used to display all elements in form include Form Elements, Local Variable, and Form Properties
Label1.Text -> is used to set the text in the Label named Label1. The name of the Form elements can be changed in properties windows of each form element.
Me.TextBox1.Text -> is used to get the text in the TextBox named TextBox1.

To run your program, you can press F5 in keyboard or you can press Play (Green Button), usually in the top of main windows. If you run it, fill the text box and click the button1 it will be like this picture:












If you want to ask me about it, just give me some comment. You can add more than 1 label or textbox if you want to more practice. 

It's simple right. Thats is just a begining for us. If you want to know more about VB and  what else can  wedo with VB, stay on this site. God Bless. Viktor Mononimbar (VB Maniacs).

1 komentar:

  1. Now, i am studying about VB. When I found this article, it gives me some information that very useful for my study. I hope you will explain about many others windows component on VB. Anyway, I have a great site for you. Please visit this site. I'm sure you will like this. Comet Clearance.

    BalasHapus