VB-UNIT-1-Notes
VB-UNIT-1-Notes
FEATURES OF VB 6.0:-
▪ It is based on the BASIC language.
▪ Programming objects and Events.
▪ A common programming platform across all MS office
application.
▪ Native code Compilation.
▪ It Supports 32-Bit application.
▪ A quick and easy way to develop application.
▪ It includes many wizards that can automate tasks or even
automate coding.
▪ It includes new object types called FILE SYSTEM OBJECT
(FSO).
▪ It includes fourteen additional functions in VB6.0.
▪ It enables you to create ActiveX controls.
▪ Visual Basic6.0 includes ActiveX Data objects (ADO) as the
Visual data access tool.
▪ VB development environment includes extensive editing and
debugging tools.
CUSTOMIZING A FORM
IDE:
Visual Basic program are created in an INTERGRATED
DEVELOPMENT ENVIRONMENT (IDE). The IDE allows the programmer to
create, run and debug Visual Basic Programs conveniently. IDE allows a
program to create working programs in a fraction of the time that it would
normally take to code programs without IDEs.
FEATURES OF IDE:
➢ Break points can be toggled simply with a mouse click.
➢ Bookmarks can be placed for quick location.
➢ Properties in the property window can be manipulated
alphabetically or even by category.
➢ With a click of a mouse button, all highlighted code will be
commented or uncommented.
➢ Aligning and formatting can easily be applied to one or more
control.
➢ Applications in VB are developed in the Integrated
Development Environment (IDE).
COMPONENTS OF IDE:
1. Menu Bar 6. Code Editor Window
2. Tool Box Window 7. Form Layout Window
3. Form Window 8. Object Browser
4. Properties window 9. Context Menus
5. Project Explorer window 10. Standard Tool Bar
MENU BAR:
The Menu Bar helps you to perform various tasks. It is displayed
directly below the title bar and includes a list of options. Each option on the
Menu Bar has a drop-down list of items that are related to the option chosen
from the menu bar. Access keys and shortcut keys are provided for most of the
options.
File Edit View Project Format Debug Run Query Diagram Tools
PROPERTIES WINDOW:
The properties window lists the design time properties for
selected objects and their current settings. A property is a characteristic of an
object such an size, Caption or colour etc.
Procedure/Events List Box: Lists all the events recognized by VB for a form
or control displayed in the object box. When you select an event, the event
procedure associated with that event name is displayed in the code window.
Two different views of the code are available in the code-editor window.
You can choose to view a single procedure or all the procedures in the
module at one time. Each procedure is separated from the next by a line.
OBJECT BROWSER:
It lists objects that can be used in the project and gives you a
quick way to navigate through the code. It also displays classes,
properties, methods, events and constants in your project. Objects from
other application can also be displayed.
CONTEXT MENUS:
• Standard
• Debug
• Edit
• Form-Editor
To View the Tool Bar
Standard Tool bar: The standard toolbar contains buttons that are shortcuts to
some commonly used menu items. Some of them are open project, save project,
cut, copy, paste, Add Form, etc….
Edit Tool bar: This toolbar contains items to assists in editing VB code.
Debug Tool bar: This toolbar contains items to assist in finding errors in the
code during a debugging session.
Form Editor Tool bar: This tool bar assist in adjusting item on the forms.
End sub
▪ Write the code for the click event.
▪ Save the project by selecting save project from the file menu
option.
▪ Save the form as sample.frm and the project as
sampleprg.vbp.
▪ Run the application by selecting start from the run menu
option or press F5.
FORM PROPERTIES:
Caption:
Caption property sets the title of the form. Caption is used to identify the
form when we minimize the application.
Name:
This property is used only in code. Returns the name used in code to
identify an object. The default name “FORM 1”. This property is different from
caption property.
Border Style:
Sets the border style of the object. Border style offersonly a small number
of choices. If you select the border style property you will get drop down list
box with values and description.
Enabled:
Set a value that determines whether an object can respond to user –
generated event.
Font:
Returns a Font Object. The property that set in an ordinary dialog box.
Startup Position:
Property gives you another way to decide on the initial position of your
form at run time. It is generally more precise than using the form layout
window.
VB CONTROLS:
Controls are used to get user input and display the output with the help of
controls; you can access remote application and data. Every control has
its own properties, methods and events.
CATEGORIES OF CONTROLS:
PROPERTIES:
TEXT BOX:
A text box control is used to obtain fill in the blank information from the
user or to display information provided by the application.
PROPERTIES:
EVENTS:
COMMAND BUTTON:
PROPERTIES:
EVENTS:
FRAME CONTROL:
PROPERTIES:
OPTION BUTTON:
An option button is a round radio button that you select to turn an option
ON or OFF.
PROPERTIES:
CHECK BOX:
A check box control is used to give the user a True or False option. It
allows the user to select one or more options from a list of independent
options.
PROPERTIES:
List boxes are used when you have a fixed list of choices. VB
automatically adds vertical scroll bars whenever the list box is too small for all
the items it contains.
PROPERTIES:
This property determines the name visual basic uses for the event
procedures.
The limits on a control name are the same as for form names:
➢ The message box is one of the best ways to display a message to the user
during execution of the application.
➢ Unlike controls on a form, the message box that appears will pop up as a
dialog box.
➢ After the user reads the message displayed OK button should be clicked
to continue with the process.
➢ The message box not only displays data in a pop-up dialog box, it can
also display an icon or more action button for the user to choose from.
➢ It is capable of writing text data to the screen, which contains the message
one wants to display to the user.
SYNTAX:
MsgBox(“Message”);
EXAMPLE:
Image controls hold Pictures. Image controls can be used to display icons
or pictures created with a program. Image control is in Tool Box.
PROPERTIES:
EVENTS:
ACCESS KEYS:
Grid is so important for accurately position controls, mastering it will help you
to give your application a finished, professional look.
Tools Options
PROPERTIES:
Show Grid You can turn the grid ON or OFF by changing the
show grid setting. The default setting is ON. There is
usually little reason to grid OFF.
Grid Width, The width and height text boxes let you set the distance
Grid Height (in twips) between grid marks. The default is 120
Boxes twips.
Align Controls The align control to Grid check box determine whether
to Grid controls automatically move to the next grid mark or
whether they can be placed between grid mark.
EDITIG TOOLS:-
DATA TYPES:
VARIABLES:
The Variable name is used to refer to the value in the variable and the
data type determines the type of data that the variable can store.
DELARATION OF VARIABLE:
SYNTAX:
EXAMPLE:
✓ Variable Length
✓ Fixed Length
Variable Length:
Example:
Str=”Hello”
Fixed Length:
A fixed length string variable is a string variable whose size of the string
is assigned at design time. The size of the variable is fixed it remains constant.
Example:
A type declaration character is a symbol that specifies the data type of the
variable you can declare and specify the type of the variable by using a type
declaration characters.
Dim Num%