TechCSE: VB Control

VB Control


Intrinsic VB Controls

Label:
In the intrinsic control first is Label control. By Label you, the programmer show anything that
you want. To add a label in your form keep maintain these steps :
1. Start a new Standard application.
2. Select the label from tool box.
3. Drag it into the form.
Go to the properties and change the caption with your name or else. If you want to change the front
color the go to Font and ForeColor respectively. You can also change the background color of the
label by clicking on the BackColor or if you want to change the background transparent press
BackStyle and choose 0 – Transparent. The name of your label is initially Label1,you can change it as
you want.
TextBox :
TextBox is another tool by which you can get input from user. Just like label plase a text box in
your form. At first the Text property shows ”Text1”. Clear that. To make the text box multiple line
select MultiLine and make it True. And to intoduce a scrollBars select ScrollBars and select which
you want. For any password program select the PasswordChar and place any character. As result of this
when user type in the textbox it will show only the character you choose.
Command Button :
Command button is nothing but the buttons which are used in the programs. Drag the button on
the form and add the code by clicking upon it twice. Before add the code change the caption as you
want. After clicking a window will open named
Project_Name – Form1 (Code). And in that window
Private Sub Command1_Click
End Sub
The Private means it private in nature, Sub means the sub routine, Command1 represents the name of
the button, and the Click means this code will execute when the button will be clicked by the user. You
can change it as per your program by clicking on the upper-right arrow of the form.
Now write the following code between the two lines.
Label1.Caption = Text1.Text
The text written in the TextBox1 will be shown in Label1 when the user click the Button. Now run
your program.
Here you can see that Hello World! Is written in text box
And after press ok in the label it shows Hello World!.
Option Button & Check Box :
These two are used for choose options, Option button is for choose only one option and check
box is for more than one options. Just drag these into your form. One thing you have to remember that
if in the option button or check box the option which is chose the Value is 1,True and other is 0,False
After changing the Caption write the code
Option1.Value = True
Check1.Value = True
Mainly this is implemented under If Else condition,
ListBox and ComboBox :
As name ListBox you can gauss this is basically a list. So drag it into your form and go to the
properties. Select List and enter the list of yours.
In ComboBox add the list(same as ListBox) and run. Click on the down arrow showing in the
form. It will show the list of the item that you entered. Select the item and its named as
Combo1.Caption.
DriveListBox, DirectoryListBox, FileListBox :
Driver list box shows all drives present in your computer. Directory list shows the directory
(sub folders) of the chosen drive. And the file list box shows all the files present in the directory.
Private Sub directory()
filelistbox.path = dirrectorylistbox.Path
End Sub

No comments:

Post a Comment

Copyright © TechCSE Urang-kurai