Refer Introduction to VB before starting this session :
Before going to to create any application in VB , keep this in mind that , you have to follow 3 main steps as;
- Create the interface
- Set properties
- Write code
1 : Create the interface :
To create an Interface , we need FORMS , as shown below :
For creating objects in our form, we need tools . There is a number of tools in the TOOL BOX as shown below :
In detail:
See an example to print Hello Friend..Click the below given link :
"Program to Print "Hello Friend" .In this example, we are using COMMAND BUTTON and LABEL for printing HELLO.
That is we created an Interface with a command button and a label for displaying HELLO.
2 : Set Properties :
The Properties window provides an easy way to set properties for all objects on a form.Below given is the Property Window (View ->Property window).
Change the names as given below :
- CAPTION form1 to HELLO
- Command Button COMMAND1 to PRINT (Here, CAPTION of the button is PRINT , and the name of the same is COMMAND1 , which is used in writing code).
- No need to change name of Label1.(If you set the name of LABEL1 as BLANK , then only PRINT command button is visible )
( For an object , there are 2 main properties , namely , CAPTION and NAME .If we change the CAPTION , it will display as the object name in the form . NAME is used to write code).
And the new form , after setting properties should look like this :
(By doing programs in VB, you will be able to understand more about each properties. You can't remember the PROPERTIES by simply telling them).
3 : Write Code :
Double-click the form or control for which you choose to write code.
This is the code editor window.
Private Sub Command1_Click()
Label1.Caption = "Hello Friend"
End Sub
After writing code , the code editor window is :
(Note that we changed the LOAD event to CLICK event).
Then RUN-> START or F5 to run the project.
1 comment:
wow..nice..blog
Post a Comment