Notes of Visual basic

History of Visual basic

Visual Basic evolved developed from Basic Language. Basic was developed in 1960 by professors John Kemmeny and Thomas. It was developed as a language for writing simple programmers to help people learn how to program.
With the development of Graphical interface (G.U.I) for personal computer (Micro soft windows) in 1980 the version of Basic develop which is suitable for GUI environment is called Visual Basic. Micro Soft Corporation developed Visual Basic in 1991.
Visual Basic is a Microsoft Windows programming language. It provides an integrated development environment (IDE) for creating application. In this environment programmer can create, Run and debug the program.
There are three different edition of visual Basic were introduced. Each edition provides specific feature and is suitable for a specific set of environment.
1- Visual Basic Learning Edition
2- Visual Basic Professional Edition
3- Visual Basic Enterprise Edition

Advantage of Application developed in Visual Basic

When we work with procedure-oriented language which are executed without any action perform by the user and program is executed statement by statement until they reach a decision Point written in to the program and interrupting an on going action is impossible and programmer set all environment just like screen display and user interfaces and write code to do every thing.
These difficulties can be removed or reduced by event driven language.( e, g ) ( Visual Basic )
Visual Basic is object-oriented .It use ready-made objects, and it is event-driven.
( i , e ) all the activities in program are triggered by an event. Each object has its event- handling producer. V.B Knows all about these already (e , g ) what a button is and how it works programmer just determine where , how and when an object appear on screen , what its caption what happened when an event occurs. This event may be mouse click, typing text, and pressing key form keyboard. Programmer does not have to write code to trap these events. Systems do every thing automatically.

Terminologies used in V.B

1- Form :-
Form is central unit in V.B. it is a window. Initially blank in which we paste different control to design the output, which display on the screen. It can be any size or color and you attached code that will run when form is lode. In one project we use one or more then one form each form is save with separate filename with extension .frm
2- Control :-
These are object, which can placed on forms (e, g) Label, Picture Box, command button check box etc. Every control has its own properties, which are set before and during the execution of program.
1- Code:-
It is set of instruction written to perform action when any event is occur. ( e , g ) When mouse is click or key is pressed.
2-Module:-
Code that is attached to from is accessible from any where on that from but a project may have more than one form-some time we write those type of code that can be reached from any form for this purpose we write module and saved a separate file with extension. (.Bas)
3- Project :-
Project hold together various forms and Modules that make up a program when you start work on a program you only have to open project file with extension (.VBP).
4- Event :-
Event is an activity that occurs during execution of program such as mouse click, pressing key form of keyboard. Each event has its own procedure.
Procedure:-
All code in a program is written in procedures or sub routines. Most of these attached to control or to an event belonging to control. All procedure start with sub (reserve word) and close with end sub (reserve wood).


Syntax:-
	Private Sub Object event-name(Parameters)
		Visual basic statements
	End Sub

Visual Basic IDE

Visual Basic is both tools and language. These tools are visual basic IDE (Integrated Developed Environments). It provides the facility for designing, writing, debugging and running programs. It is use to develop the GUI of the program. The language is used to write the code that execute behind the GUI of program.
Visual Basic Environments or Components of Visual Basic IDE
Visual Basic IDE consists of various components and the following windows.
1) Form Windows or Form Designer
2) Form Layout Windows
3) Properties windows
4) Project explorer Windows
5) Tools Box
6) Menu Bar
7) Toolbar or Icon Toolbar
8) Immediate windows

1)Form Windows or Form Designer:
This window of Visual Basic IDE is specially used for designing the form at designed time. Form windows contain a form named "Form1” by default every form have name Form1, Form2, form3 respectively and all the control (Object of Visual Basic) are past on this Form.
2)Form Layout Window: -
Form Layout Window specifies the position of the program windows on the computer screen when the program is execute. It consists of computer screen and form. The position of active form is shown on this computer screen.
3)Properties Windows: -
The properties of and object in visual basic are attribute of an object such as size, color, font etc. Properties windows display these attribute of the selected object.
Each object in Visual Basic has unique set of properties some properties such as height, width, name, color etc common to all while other properties are unique to each object. When an object or control is select then properties windows display respective properties.
Properties windows contain two Tab: Alphabetic and categorize. When first Alphabetic option is selected then properties listed in alphabetic order. This is default setting. Similarly when Categorize is selected then properties are listed as group categories.
3) Project Explorer: -
Project explorer display the information about form, modules and classes used in the project. This window is used to bring particular components of the project in focus. For example if project contain three forms and one is open then double click on form icon display the form and brings focus in IDE.
Project Windows contain three buttons.
1) View code = display the code windows
2) View Object = Display the selected object.
3) Toggle Folder= Is used to Hide And Show the folder.
4) Tools Box: -
Tools box contain the control (Also Called Object or Active X Control) that are used on the form windows to develop an application. These Controls are basic Components of GUI (Graphical User Interface) such as Button, Check Box, and Text Box etc. Tools box contain most of the tools that are usually used in application program created in visual basic. How ever new tools are also added to the tools box. Similarly some extra tools are also available in professional and Enterprise Edition of Visual Basic and these can also added to toolbox.

Tool Box contain following control (Objects).

1) Pointer It is used for only select, move, resize the control on the form.
2) Label It is just like a title display the message and also use for the output.
3) Text Box It is used to get the input and also for out put.
4) Frame Frame combine number of control together.
5) Command Button It is click able button and use to perform any action.
6) Check Box It is used to get the input. It can have tow states Checked and Unchecked.
7) Option Button It is also called radio button. It is also used for input and have tow states checked or unchecked.
8) List Item Its provide the list of item and used as input.
9) Combo Box It is used to provide a short list of item
10) Hscrollbar Its display the Horizontal Scrollbar.
11) Vscroollbar Its display the vertical scrollbar.
12) Timer It is not visible at run time but it perform task at regular interval.
13) Drive List Box Display the Drive List In the computer.
14) Dir List Box Display the directories of the selected Drive.
15) File List Box It is used to access the files in selected directory.
16) Shape Its help in making drawing object like that circle, rectangle etc
17) Line It is use to draw the line.
18) Image It is use for display the image on specific location.
19) Picture It is also used to display the image but it is differ form image.
20) Data Control It is used for connecting to database.
21) OLE It is used to communication with other windows application.
5)Menu bar: -
The Command that are available for developing, maintaining and executing Visual Basic programs are given in menus. For Example File, Edit, View, Project are the menu.
Toolbar or Icon toolbar: -
These are the short cut of most commonly used command of menu bar. It contains icon (Shortcuts) of different command just like save, file, run program, stop program etc.
6) Immediate Windows: -
This window is used to find out the current stat of variable and properties in the program. It can also be used to carry out commands. When we enter a command in this window then after pressing enter key this command immediately execute. We can say that immediate window is used for debugging purpose or for execute immediate statement and result of these statement are also display in same windows immediately after pressing ENTER KEY.
7)Interfaces For Visual Basic Application:
Visual Basic application can be created into two main interfaces.
Single Document Interface (SDI):
The application which is created in SDI, consist of different Form and every Form have its own control such that maximize, minimize etc and also moved separately on screen.
Multiple Document Interface (MDI):
The application, which is created in MDI also consist of series of independent Form but one form is Considered as parent form and other Form considered as Child Form. In MDI Form we can organize all form for example MS Word is MDI application.

Properties, Methods and Events In VB

Features of object: -
Each object in Visual Basic supports three features.
(i) Properties (ii) Event (iii) Methods
1) Object Properties: -
A property is an attribute or characteristic of an object. It’s specify the appearance and behavior of the object.
The properties set from properties window during the design time and also through the coding.
These properties have some common type of value. Visual Basic Use following value to set the properties of any object.
Boolean Types: -
This type contain two value True or False .It is already given in drop down box user can select either one form these two values.
Predefine Value: -
An object property can have list of pre-defined value. These values are given in drop-down list box.
String Value: -
The properties like that name, caption are use string (text) type of value.
Hexadecimal Values: -
Some properties have Hexadecimal value like that color properties specifies in form of Hexadecimal value.
Filename Value: -
Some properties have filename value in which we specifies the name of file .For example in icon properties of form object we specifies the file name.
Size Value:-
The properties Left, width & height are called size value. In these type of value we enter the value in properties windows or resizing and moving the object on form.
2) Object Method: -
Object methods are built in function attached to object. A method is written as a command in Visual Basic Program.
Common Syntax is
Object-name. Method
For example if we want that a form is appear it is clear. Then we use a method

	Form1.cls
Difference between Object Method and Properties:
Properties is set form properties window and through the code but on the other hand object method set through only code by statement.
3) Object Event: -
Visual Basic Several object and each object have a unique function. These function perform through program or code attached with that object. These code execute when user interacts with object may be by clicking, double-click or Pressing key form keyboard. This action of user is actually message to computer and called event.
Types Of Events: -
There are several events in Visual Basic some perform by User and Some Perform automatically. Some most commonly used events, which are performed by user, are following.

Keyboard and Mouse Events in VB

1) Mouse Events

The events, which perform with the help of mouse, are called mouse events. Following are the mouse events.
a) Click Event: -
When mouse is click on any object then this event take palace.
DB click (Double Click): -
DB click events take place when we double click on an object.
b) Detecting Mouse event: -
Click event and D.B click recognize only when left button of Mouse is press but other right and middle mouse button, and when mouse move then some other events take place and called mouse detecting events.
c) Mouse Down Event: -
The mouse down event is occurring when mouse button is parsed.
Syntax: -

Private sub object_mousedown (Button as integer, shift as integer, X  as single, Y as single)
Visual Basic Statement
Visual Basic Statement
Visual Basic Statement
End sub

Where,
Button is an integer value. It is used to detect the button that was clicked on the mouse.
Shift is integer value. It is used td detect the pressing of Shift, Ctrl, Alt Keys on the keyboard.
X and Y are single value which store the position of mouse pointer on the form.
d) Mouse up event: -
This event takes place when mouse button is released.

Syntax: -
Private sub object_mouseup (Button as integer, shift as integer, X  as single, Y as single)
Visual Basic Statement
Visual Basic Statement
Visual Basic Statement
End sub

Where,
Button is an integer value. It is used to detect the button that was clicked on the mouse.
Shift is integer value. It is used td detect the pressing of Shift, Ctrl, Alt Keys on the keyboard.
X and Y are single value which store the position of mouse pointer on the form.
e) Mouse move event: -
The Mouse event occurs when mouse is move and new position is set for mouse pointer.

Syntax: -
Private sub object_mouseMove (Button as integer, shift as integer, X  as single, Y as single)
Visual Basic Statement
Visual Basic Statement
Visual Basic Statement
End sub

Where,
Button is an integer value. It is used to detect the button that was clicked on the mouse.
Shift is integer value. It is used td detect the pressing of Shift, Ctrl, Alt Keys on the keyboard.
X and Y are single value which store the position of mouse pointer on the form.

2) Keyboard Event

The event, which triggered by keyboard are called keyboard event. In simple word when we say that when we press any key form keyboard or release any key from keyboard then an event take place, is called keyboard event.

Following are the keyboard events.
a) Key Down: -
The key down event occurs when any key of the keyboard is pressed.
Syntax:-

Private  Sub    Object_Ketdown(Keycode As Integer, Shift As Integer)
Visual Basic Statement
Visual Basic Statement
Visual Basic Statement
End Sub

Where,
Key Code is integer value, which show the ASCII value of the key, which is pressed.
Shift is integer value that detects pressing SHIFT, CTRL, and ALT key form keyboard.
b) Key Up event: - This event takes place when a key of the keyboard is released.
Syntax:
Syntax:-
Private  Sub    Object_Ketdown(Keycode As Integer, Shift As Integer)
Visual Basic Statement
Visual Basic Statement
Visual Basic Statement
End Sub

Where,
Key Code is integer value, which show the ASCII value of the key, which is pressed.
Shift is integer value that detects pressing SHIFT, CTRL, and ALT key form keyboard.
e) Key Press event: -
Key Press event takes place when a key is pressed. It is differ form key down events it can not detect SHIFT, CTRL, and ALT key.

Syntax:
Private Sub Object_Keypress(Key ASCII As integer)
   Visual Basic Statements
   Visual Basic Statements
   Visual Basic Statements
End Sub

Where,
Key ASCII is an integer value. It is used to detect the ASCII value of any keyboard.

User Interface In VB

User interface is actually a way in which user can interact with computer. In visual basic the basic tools for creating user interface is FORM this is basic tools in which we place different tools which give help to user, that user communicate with computer for example user give some input and then ask to computer that perform some task just like by clicking by mouse or pressing enter key. These all elements are called user interface elements.
For designing user interface in visual basic first of all we open visual basic IDE and open a new form. After this we place different object tools from toolbox and then set some properties from properties windows. And then write code in coed windows behind each object.
Forms & its behavior
Form is most basic object in Visual Basic. It provides the base upon which the graphical user interface (G.U.I) of an application (windows base application) is created. We can place various controls on the form to perform specific function.
Components of form:-
Basic components of form are following.
1. Control Menu:-
It simple menu that contains various command related with Forms for example close Maximize, Minimize, Restore, Move, Resize.
2. Close , Maximize , Minimize Button :
These are three buttons, which control the forms window status.
3. Border: The four edges of form are called Border. It may be different style size.
4. Title Bar: - It contains control Menu and close, Maximize, Minimize and close button and also name of the form (window). If we double click on the Title bar it also minimize or maximize (maximize /restore) the Form.
5. Grid : - The equally spaced dots on form are called grid. Grid is used as a guide for placing various controls on the form. The grid is not shown when program is executed.
Properties of Form: -
Following are the common and important properties of form.
1- Form Caption: -The title of form, which appears on the top of the form, is called caption. By default caption of forms is form1. For changing the caption we select caption in properties window and write new title of form.
2- Form name: - Each form have unique name. This name is used in coding for reference specific form.
3- Auto redraw: - This property has two values True Or False. If True than text display on the Form if false then text is not display on the Form.
4- Border Style: - When form is appear its border style is control by border style in properties window. There are six predefine size we select one of them.
5- Background color: - We also control Back Ground color by this properties this properties contain number of different color. The color setting is defined in hexadecimal number but it is difficult that we remember all color value in Hexadecimal number. So we use color plate and select any color window automatically convert its code in hexadecimal number.
6- Control Control box: - Control Box is appear on top left corner of the form and contains minimize, maximize, restore and close command. It appears when border style (0,1,2) is selected. There are two setting True OR False. When setting is true control box is displayed and if false then not displayed.
7- Enabled: - This property has two values True or False if True Then We accesses the form at Run time and if False then we cant access the form at run time.
Font properties: - The text on a form is displayed in a format that is defined in this property.
8- For ground color: - This property determines the color of text and graphic on the form.
9-Height and Width: -These two properties control the Height and Width of Form.
10- Icon: - This is used to specify the picture for icon. When project is complete and its executable file is created this picture assign its icon.
11- Mouse Pointer: -Change the shape of pointer. We can select predefine type of icon.
12-Mouse Icon: - If Mouse Pointer set as custom then We specify the icon file name for mouse pointer then mouse pointer will be change.
13-Movable: - If movable property set True Then we can Move the form by dragging and if Movable value is set False then form not move.
14-Picture: - In this property we specify a graphic file name for background Picture. 15-Show in task bar: - This property specifies whether or not Form is displayed as a button taskbar. It has two logical values true or false. If true forms Icon is displayed on task bar (Status Bar) other wise not displayed.
16- Visible: - If Visible set as False Then form not display on the screen when we execute the project.
17- Start up position: - When program is execute the form is displayed normally different Places. We can control its startup position by this property. These are also 4 pre define value.1. V.B startup Manual (No setting is define)2. V.B startup Owner (center of windows)3. V.BstartupWindows (Appear corner of window)4. VbstartupScreen (Center of screen)
18-Windows State: - The size of the form at runtime whether normal, maximized or minimize is called state of window. Also contain three predefine type:(i) V.B Normal (ii) V.B Minimized (iii) V.B Maximized

Active X Controls in VB

The graphical user interface of program consists of several components or object. These object are the building block of the GUI (Windows base application).
These object are called control or Active x control.
Visual basic has two types of controls.
1) Basic Active X Controls
2) Advanced Active X Controls
Basic ActiveX Controls are also called standard controls. These are provided by the visual basic in its tools Box. These are also known as intrinsic (built-in) controls.
Advanced Active X controls are provided as separate files on the disk. These are laded in Visual Basic IDE. Through the component Dialog Box.
Basic Active X Controls: -
Following are the basic Active X Control
1. Command Button
2. Frame
3. Check Box
4. Option Button
5. Label Control
6. Text Box
7. List Box
8. Combo Box
9. Scroll Bars
10. Timer Controls
11. File Controls
12. Drive List
13. Directory List
14. File List

1. Command Button

It is most common element of GUI. It is used to execute an action when it is clicked or pressed by key. Clicked event of the command button is most commonly used. We also use button access key to access the command button through the keyboard.
Properties of the command button: -
i- Name: - In this property we specify the name of button. This name is used during the coding as reference of command button. By default this name is command1, command2, command3…and so on. But we should be changing this name.
ii- Caption: - Caption is actually title of the command button. Which is shown on the button.
iii- Enabled: - In this properties specify that this button accessed or not by any event. This properties have tow logical value True or False.
iv-Font: - Font properties set the font of text for Caption.
v-Height and Width: - This property set the height of the button. We also set the size by Mouse Dragging.
vi-Back color: - It specifies the Background color of the button. This properties have some Hexadecimal value but we also select the color plate and then select the any color from properties windows and if we want to change the color of button through code the we use Vb constant name of the color for example for blue color we use vbblue.Note that we must set style property as graphical
vii-Style: It is vary important property. It shows two value Graphical and Standard. If we select standard then some properties like that Back color, picture etc are not work. These properties work only when graphical value is select.
viii- Picture: - This property set the picture that display on button.
ix- Disable picture: - In this property we select the picture. When Enabled properties set False, Then selected picture is shown on place of button.
x- Down Picture: - In this property we also select the picture. When we clicked on the button then this picture take place.
xi- Visible: - This property set two values. True and False. If the value is true then button is visible on the form at time of execution if false the not visible.

What is Button Access Key

Clicked events of the command button also access form the keyboard. Key that is used to access the clicked event of the button on the form is called Button Access key.
It is actually combination of Alt and any other single character key of the keyboard.
The latter to be used with Alt key to access the button is defined while we specifying the caption of command button. We placed ampersand sign (&) before the specific character and access key character under line on the button.
For example:
&Eexit
Exi&t

2. Label Control

It is use to display the text as message or heading. User cannot directly edit the label. It is edit form the properties window or through the coding .The text enter through the caption properties.
Properties of the label box: -
Name: - In this property we specify the name of Label. This name is used during the coding as reference of Label. By default this name is label1, label2, label3…and so on. But we should be changing this name.
Caption: - This Property specifies the text on label. Auto Size: - This property can be either True or False. If True then label resized to fit the text into the label and if False then size of the label remain fixed.
Alignment: - It Justify the text in the caption. This property has three predefine value.Right justify, Center, Left Justify
Back Style: - This property has two values Opaque and Transparent. If set Transparent Then Label Background is transparent.
Back color: - It specifies the Background color of the Label. This properties have some Hexadecimal value but we also select the color plate and then select the any color from properties windows and if we want to change the color of label through code the we use Vb symbolic constant name of the color for example for blue color we use vbblue.
For ground Color: - It specifies the color of the text on the label. The selection of color same as Back color.
Font: - Font properties set the font of text for Caption.
Height: - This property set the height of the label.
Width: - These properties set the width of label.
Visible: - This property set two values. True and False. If the value is true then label is visible on the form at time of execution if false then not visible.
Word warp: - If auto size property is set True then this property work on two values True and False.If true then text will be wrap and label will expand vertically and if false then text will not warp and label expand horizontally

3. Timer Control: -

The timer control is to generate an event at regular interval. The event generated is called timer event.
The timer control is used for that type of work, which gives response at regular interval for example, to move the graphic or to change the color at regular interval. It can be placed anywhere because it dose not display on the screen at run time.
Properties of the timer control :-
Interval:-
Most important property of the timer control is interval property. It specifies the interval between each timer events. It measured in millisecond. So 1000 interval is equal to One second.
Enabled:-
This property work as timer ON and OFF function. If this properties is true then timer work if false then timer not work.

4. Text Box : -

This control is used to get and display the data on the form. The information in the text can be entered at design time and also run time.
It is most commonly used control of the windows user interface (GUI).
Properties of the Text Box: -
Name:
Every text box have unique name, which is used as reference of this text box in the coding. By default Text box have name text1, text2, text3. And up to so on. But we also change this name.
Text:
Text property is actually text of the text box, which is entering in the text box during design time and also run time. Max Length:
This properties specify that how many character entered in the text box are how many character text box display.
Multi Line:
This property specify the wither the text box is single line box are multi line box.
Password char:
It specifies the character that is displayed in the place of original character that is entered in the text box. This property is normally used for password and text converted as ( * ).
Scroll Bar:
This property work when multi line property is true. Then this property specifies that scroll bars are displays are not.
SelLength:
This property is used only at run time. It returns the length of the selected text box.
SelStart:
This property is used only at run time. It returns the starting position of the selected text in the text box.
SelText:
This property is used only at run time. It returns the selected text in the text box.
We also Use some common property in the text box, which are following.
Back color property, Enabled property, Font property, For color property, Height and width property, Mouse Icon and Mouse pointer property and Visible property. See these properties in Topic Common Properties.
Text Box Events: -
1) Change Events: -
This event takes place when there is any change in the text box.
2) Lost Focus: -
This event takes place when user leaves the text box and control is transfer to next object.
3) Key Press: -
This event takes place whenever a key is pressed.
Text Box Method: -
1) Set Focus: -
This method placed the curser in the specified text box.

5. Check Boxes: -

Check boxes are used to input the information. Check boxes are used when one are more then one option may be selected form a list of given option. An option is selected by clicking on the specific check box. When an option is selected, a tick mark (P ) appears in the box . So a tick or may be cross in the box indicate that the option is selected.
Properties of the Check box: -
Name: -
Every check box have unique name, which is used as reference of this check box in the coding. By default check box have a name check1, check2, check3. And up to so on. But we also change this name. i. Caption: -
This property set the text that appears next the check box.
ii. Font: -
This property set the font, style, and size of the text, which we enter in the caption property.
iii. Value: -
This property indicate the status of the check box, either it is selected are no.
There are three statuses.
1. Uncheck Status: -
Return zero ( 0 ), vbunchecked.
2. Checked Status: -
Return One ( 1 ), vbchecked
. 3. Grayed Out: -
Return Two ( 2 ), vbgrayed.
We also Use some common property in the Check box, which are following.
Back color property, Enabled property, Font property, For color property, Height and width property, Mouse Icon and Mouse pointer property and Visible property.
See these properties in Topic Common Properties.
Check Box events: -
1) Click Events: - Click events very important event it takes Place when check box is clicked.

6. Option Button: -

Option button are also called radio button. These are used when only one option from set of given option is to be selected. When one option is selected then other cannot be selected.
Radio button is selected when we click on the circle of the radio button.
Properties of option button: -
Name: -
Every option button have unique name, which is used as reference of this button in the coding. By default option button have name option1, option2, option. And up to so on. But we also change this name.
i. Caption:-
ii. This property set the text that appears next to the option button.
iii. Font: -
iv. It set the type of font, style, and size of the text, which we enter in the caption property.
v. Value: -
vi. It indicate the status of the option button, either it is selected are no. There are two statuses of check box selected or not selected. For this purpose we set this properties true or false. Where True specify selected and false specify not selected. Only one option button have true value form a group of option button.
We also Use some common property in the option button, which are following.
Back color property, Enabled property, Font property, For color property, Height and width property, Mouse Icon and Mouse pointer property and Visible property.
See these properties in Topic Common Properties.
Option Button events: -
1) Click Events: -
Click Event is very important event it takes Place when option button is clicked. When option button is clicked then value property is automatically change.

7. Frames : -

Frames are used for grouping related control on the form. So a frame is used to contain other controls. It is also called container control.
For this purpose first frame is drowned on the form and then control are drowned on the frame
Frame Properties: -
Caption: -
These properties specify the title of the frame, which is appearing on the head of the frame.
Font: -
This property is used to set the font, style and size of the text that we enter in the caption property.
Border style: -
This property set either non or fix single which specify the type of border.
Back color: -
This property set the background color of the frame.
Enable: -
This property has two values True or False. If True Then We can access The Frame and other object (control) that are drawn on that frame at Run time and if False then we cant access the frame at run time.
Fore color: -
This property set the font color (eg change the color of Caption of the form)
Font: -
This property set the font type and style of frame.
We also Use some common property in the Frame, which are following.
Back color property, Enabled property, Font property, For color property, Height and width property, Mouse Icon and Mouse pointer property and Visible property.
See these properties in Topic Common Properties.

8. List Box: -

List box display the list of item, from which user can select one or more then one item. This control occupies the space on the specific location on the form. If the number of the item are increased form the specify place then a scroll bar automatically added.
The item of the list box added through the list property of the list box or through the code.
List Box Properties
i- Name: -
In this property we specify the name for selected list box, which is used as a reference of this list box during the coding. By default this name is List1, List2 and so on.
ii- List: -
The item of the list box added through this property. If we add the item through the property window then we adopted following procedure.
a. Select the list property and click the arrow at the right end, an empty box is appeared.
b. Type the item name that is to be added and press " ctrl + enter " key to gather. The given item is inserted.
c. After complete this work press enter key for closing the box.
List Count: -
This property returns the number of item in a list. It is use only at run time.
List Index: -
This property returns the value of item of the most recently selected item in the list box. If no item is selected then list index is ( -1). This property is also used at run time only.
Multiple selected: -
This property specifies that how many item to be selected at the time. In this property 3 predefine value are available. User can select any one from these values. 0 For No Multiple Selection allowed.
1 For Multiple selections is allowed.
2 For Group selection is allowed.
Selected: -
This property is use to find out whether any item is selected or not selected. If any item is selected then it return True value otherwise it return False value. This property only work at run time,
Sorted: -
When we want to display the item in the list box in sorted order then we use this property. True value is used for display the item in sorted order and false value is used for as user enters the item list box display.
Style: -
This property is used to specify the manner in which the items are displayed. For example list can be displayed as simple text or a check box is appear with the list item. For this purpose we use,
0 or vblistboxstandard: This is default setting and displays the list in simple text form. 1 or vblistboxcheckbox: This setting display the list item in shape that a check box is appear with list item.
Text: -
This property returns the text of the selected item of the list box. This is also used at run time.
Index: -
Return the index value of the item most recently added in the list box. It is only used at run time
We also Use some common property in the list box, which are following.
Back color property, Enabled property, Font property, For color property, Height and width property, Mouse Icon and Mouse pointer property and Visible property.
See these properties in Topic Common Properties.
List Box Event: -
1) Click event: -This event is triggered when an item in the list box is clicked.
2) Dblclick: - This event is occurs when item in the list box is double clicked. This is more commonly way of selection.
Method of list box:
1) Add Item: - This method is used to add the item in the list during the run time.
Syntax:
List-name . Additem "Item name”
2) Clear: - This method is used to clear the all item form the list.
Syntax:
List-name . Clear
3) Remove Item: -This method is used to remove any item form the list.
Systax:
List-name . removeitem(List-name . listindex)

10. Combo Box: -

Combo box is similar to the list box but it takes less space on the form then the List Box. It consists on of a text box and dropdown list box. It is used to display the list item and we can select the item from the list. The other advantage of Combo box is user can type the name of item in the list box are select the item form the list. So we can say that Combo Box give the features of both the Text Box and List Box.
i. Name: - In this property we specify the name for selected list box, which is used as a reference of this list box during the coding. By default this name is List1, List2 and so on.
ii. List: - The item of the list box added through this property. If we add the item through the property window then we adopted following procedure.
a. Select the list property and click the arrow at the right end, an empty box is appear
b. Type the item name that is to be added and press " ctrl + enter " key to gather. The given item is inserted.
c. After complete this work press enter key for closing the box.
iii. List Count: - This property returns the number of item in a list. It is use only at run time.
iv. List Index: - This property returns the value of item of the most recently selected item in the list box. If no item is selected then list index is ( -1). This property is also used at run time only.
v. Multiple selected: - This property specifies that how many item to be selected at the time. In this property 3 predefine value are available. User can select any one from these values.
0 For No Multiple Selection allowed.
1 For Multiple selections is allowed
. 2 Group selection is allowed.
vi. Selected: - This property is use to find out whether any item is selected or not selected. If any item is selected then it return True value otherwise it return False value. This property only work at run time,
vii. Sorted: - When we want to display the item in the list box in sorted order then we use this property. True value is used for display the item in sorted order and false value is used for as user enters the item list box display.
viii. Style: - Style property is used to select the display style of the Combo Box. This property have three (3) predefine value.
O or VbComboDropDown: It is default value it includes a dropdown window and a text box. User can select the item or enter the text in the text in the text box.
1 or VbComboSimple: O nly text box is displayed But we select item moving with arrow key or enter the text in the text box. So drop down windows id not displayed in this type.
2 or VbComboDropdownList: A drop down list is displayed and user can select any value. User cannot directly enter the text in the text box.
ix. Text: -
x. This property returns the text of the selected item of the list box. This is also used at run time. xi. Index: -
xii. Return the index value of the item most recently added in the list box. It is only used at run time
We also Use some common property in the Combo box, which are following.
Back color property, Enabled property, Font property, For color property, Height and width property, Mouse Icon and Mouse pointer property and Visible property.
See these properties in Topic Common Properties.

11. Scroll Bar Control: -

The scroll bar is graphical way of selecting values between ends of the control. It is long strip with an indicator through which a user can select a value.
In visual Basic we are use two type of scroll Bar
1) Horizontal Scroll Bar
2) Vertical Scroll Bar
Te scroll bar is dividing in to three aria,
One is End arrow on both side if we click these arrow then value of scroll bar is increase or decrease it is called small change.
Second one is bar aria. If we click any where in this aria the value is increase or decrease this is called large change.
Third one is called Thumb of scroll bar if we drag this thumb then value is increase or decrease this change in value is called Continues change.
Properties of scroll bar
i. Name:-
In this property we specify the name for scroll bar, which is used as a reference of this scroll bar during the coding. By default this name is Hscroll1 or vscrool2 and so on.
ii. Max: -
This specifies the maximum value of scroll bar by default this value is –32767 to +32768. We also fix this value on our own choice as if we use this scroll for color setting in RGB function then we fix max value to 255 because maximum value of color in RGB function is 255.
iii. Min: -
It specifies the minimum value by default it is set on (0) zero.
iv. Large Change: -
If we click in bar aria then change in value is called large change .in this properties we specify the amount of change.
v. Small change: -
In this property we specify the amount of small change.
vi. Value: -
When scroll bar move then a value return.
We also Use some common property in the Scroll Bar, which are following.
Enabled property, Height and width property, Mouse Icon and Mouse pointer property and Visible property.
See these properties in Topic Common Properties.

12. File Control: -

File control is used to locate or load a file from disk, which is already store. Visual basic provides three controls for this purpose.
1. Drive List Box:
Drive list box provide the facility that we can chose any drive from computer. When we click on drive list box then dropdown list is displayed which have different drive name of your computer and we can select any drive.
Property of Drive Box:
i. Drive property: -
The main property of drive list box is drive property. it returns the drive name which is currently selected.
We also Use some common property in the list box, which are following.
Enabled property, Height and width property, Mouse Icon and Mouse pointer property and Visible property.
See these properties in Topic Common Properties.
2. DIR List Box:
This box displays the list of folder and subfolder of the selected drive.
Property of Drive Box:
i. Path property: -
This property specifies the current folder path selected by the user.
Events perform on Dir List box A change event is triggered whenever folder selection is change in the dir box.
3. File List Box
This box displays the file name of the selected folder in the dir box.
Properties of File Box i. Filename property: -This property return the filename of the selected file in the file box.
ii. Path property: -This property return the path of the selected file.
iii. Pattern: -In this property we specify the file type, which we want to display in the file box.
For this purpose we used wildcard character * and ?. For example if we want that the files, which are displayed in the file box, are have extension .DAT then we specify in this property.
. Dat
If we want to display all type of file in the file list box then we set this property *.*.
We also Use some common property in the list box, which are following.
Back color property, Enabled property, Font property, For color property, Height and width property, Mouse Icon and Mouse pointer property and Visible property.
See these properties in Topic Common Properties.
File list box events
1) Click: - When a file name is clicked in the box then this event is performed.
2) Dbl click: - Whenever a file name is double clicked then this event performed.
3) Path changing: - This event trigger whenever the path is change in the file list box.

Some Common Properties of Active Control In VB

1) Name: -
Each control in Visual Basic have unique name. This name is used at time of coding as reference to specific object when we call that objects.
2) Back color: -
We also control Back Ground color by this properties this properties contain number of different color. The color setting is defined in hexadecimal number but it is difficult that we remember all color value in Hexadecimal number. So we use color plate and select any color window automatically convert its code in hexadecimal number.
3) Enabled: -
This property has two values True or False if True Then We access that specific object at Run time and if False then we cant access that object at run time.
4) Font properties: -
The text on object is displayed in a format that is defined in this property. We set type, size and style of font in this property.
5) For ground color: -
This property determines the color of text and graphic on that object.
6) Height and Width: -
These two properties control the Height and Width of the specific object
7) Mouse Pointer: -
Change the shape of pointer. We can select predefine type of icon.
8) Mouse Icon: -
If Mouse Pointer set as custom then We specify the icon file name for mouse pointer then mouse pointer will be change when mouse is move on that specific object.
9) Visible: -
If Visible property set as False Then specific object not display on the screen or on the form when we execute the project.

Visual Basic Programming

See More Visual basic Programming Notes Visual Basic Notes Part-2