Vb-unit-4-NOTES
Vb-unit-4-NOTES
Vb-unit-4-NOTES
VB OBJECTS
1
File Open and File save dialog boxes:-
Show open method is used to show an open dialog box, the show
save method is used to display the File Save dialog box.
PROPERTIES:
PROPERTY DESCRIPTION
Default Ext Default Extension for the files.
File Name Name and full path of the file.
File Title File Name without the path.
Filter Affect the type box in the dialog box. Format
the description string, the pipe symbol, the
filter and so on.
FilterIndex This is used when you set up many filters.
Flags This property is used to set a various
possible option and how the box will look.
InitDir Specifies the Initial directory
Maxfilesize Sets the maximum size of the file name.
ColorDialog Box:
Color dialog box, you use the showcolor,method of the common
dialog control. The flags property controls this dialog box.
EXAMPLE:
CommonDialog1.Flags = cdlccFullOpen
FONT DIALOG BOX:
Dialog box by using show font method of the common dialog
control. There are 15 different flags property values for the font
dialog box.
2
PROPERTIES:
PROPERTY DESCRIPTION
Color Only used for color printer
FontBold,FontItalic If the cdlcfEffectsflags is set, you can
FontStrike,FontUnderline allow the user to choose the property.
Font Name Sets or return the font name.
Font Size Sets or return the font size
Max,Min These affects the font sizes in the size
box.
3
COMMON CONTROLS:
Choose Microsoft windows common controls 6.0 from project
menu in that select components dialog box.
1. Image list control:
The image list control gives you another way to store a
group of images in a single place.
The key to working with an image list control knows
about list image objects. Image control work with
property page.
2. Toolbar control:
o The toolbar control makes it easy to build tool bars into
your windows 95 projects.
o If you intend to set the images at design time, the
associated image list control must be on the same form
as the toolbar control.
4
AUTO SIZE PROPERTY HAS THREE POSSIBILITIES:
CONSTANT DESCRIPTION
SbrNo Autosize (Default) No automatic resizing
occurs.
SbrString Parent form resize and extra space
available, the panel resizes by
dividing the available space.
SbrContents The panel resizes to fit its contents if
space is available.
PROPERTY:
0 – Size and location
1- Top of the form
2- Bottom of the form
3- Left aligned at the edge of the form
4 - Right aligned at the edge of the form
5. TREEVIEW CONTROL:-
The tree viewcontrol, as its name suggests, lets you build
an outline similar to the one used in windows explorer. The
individual objects are usually called nodes.
5
6. LIST VIEW CONTROL:
The listview control let’s you display items in various ways,
essential the ways you see when working with the windows
desktop.
PROPERTY:
PROPERTY DESCRIPTION
Icons Returns sets the index or key for the
icon.
Selected Tells you whether the list Item was
selected.
Small Icons Returns or sets the string representing
the data for the sub item.
Text As you might expect, this is the text the
user sees.
7. TABSTRIP CONTROL:
Tab strip control provides another way to give a form the
look of a tabbed dialog box. It is not as flexible as the tabber
dialog box.
8. SLIDER CONTROL:
The slider control works similarly to a scroll bar. It is a little
boxwith option tick Marks the containa slider.
6
MENUS:-
Designing the right kind of menus will make your
application much more user-friendly. Menus that contain
Submenus are usually called Hierarchical menus.
Menu Editor:-
Create menus is VB by using the menu Editor window. Choose
tools menu in that select menu editor (or) ctrl+E shortcut key.
7
Caption text box:-
Caption show up the text area inside the dialog box. Menu item
will not have default caption.
Name Text Box:-
Menu item must have a control name. Menu item is a
part of a control array. They have different control name.
OK and Cancel Button:-
Click ok when you finished designing the menu. Click
cancel if you decide not to build the menu at all.
Index box:-
Index box is used when menu item as part of a control
array. You can add new instances of a control at runtime.
Shortcut box:-
Box lets you add accelerator keys to your menu items.
Windows List Check Box:-
Used when you have MDI windows.
Help contextId box:-
This is used when you are adding a help system.
Checked check Box:-
Determine whether a check mark showup in front of the
menu item. The default check box is off.
Enabled check off:-
Determine the value of the enabled property of the menu item.
A menu item that is enabled will respond to the click event.
Visible check box:-
8
Determine the value of the visible property of the menu item. If
a menu item is made invisible, all its sub menu are also invisible.
Arrow Button:-
These buttons lets you work with the current menu item.
Next Button:-
Clicking the next Button moves you to the next menu item and
inserts a new item if you are at the end of the menu.
Insert Button:-
Clicking the insert button inserts a menu item above the
currently highlighted menu item.
Delete Button:-
Clicking the delete button removes the currently highlighted
item.
MDI FORMS:-
MDI stands for MULIPLE DOCUMENT INTERFACE. MDI is
used to open multiple documents in a single window.
9
Add a new form to the project by selecting the Add
Form option in the project menu.
Select the MDI Form icon in the new tab of the
Add MDI Form dialog Box and click on the open
button.
This will add an MDI Form to the project. Change
the name property of the MDI Form to parent form.
Set the MDI child property child form1 and child
form2 to true.
Add a menu to the MDI with the following property
setting shown in below table.
CAPTION NAME
&Open MnuOpen
&Childform1 Mnuform1
C&hildform2 Mnuform2
&View Mnuview
C&ascade Mnucascade
TESTING:
Once a program becomes in any way complicated,
no matter how carefully you outline your program
or how carefully you plan it, it probably won’t do
what you expect at first.
10
Once the testing process convinces that there are
bugs lurking, we need to find them and then
eradicate them.
ERRORS:-
When an application runs, an error occurs if a statement in
the code attempts to execute an invalid operation.
TYPES OF ERRORS:-
1. SYNTAX ERROR:-
Syntax error occurs from an incorrectly written code,
such as an incorrectly typed keyword, omitted punctuation or an
incorrectly spelled variable.
2. RUNTIME ERRORS:-
Runtime error occurs when a statement attempts an operation
that is impossible to carry out.
Example:-
A statement that attempts to divide by zero.
3. LOGICAL ERRORS:-
Logical errors occur when the code compiles successfully and
runs without producing error messages, but does not produce the
desired results.
DEBUGGING:-
To disable error handlers while debugging.
11
From the code window context(available by right-clicking on
the code window), choose toggle.
Select the break on All Errors Option. The debugging
techniques presented to use the analysis tools provided by
visual basic.
o Visual basic cannot diagnose or fix errors for you, but it
does provide tools to help you analyse how execution
flows from one, part of the procedure to another and
how variable and property settings change as
statements are executed.
12