Vb-unit-4-NOTES

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

UNIT IV

VB OBJECTS

COMMON DIALOG BOX:


Common dialog boxes used for opening or saving a file, printing,
choosing fonts, or setting colours.
Common dialog boxes are easy to use in principle, but they are
somewhat less easy to use in practice.
Project components Microsoft common dialog control.
Methods in common dialog box:
METHOD DIALOGBOX
ShowSave Show file save dialog box.
ShowOpen Showopen dialog box.
ShowColor Show Color dialog box.
ShowPrint Show Print dialog box.
ShowFont Show Choice dialog box.

Working with common dialog boxes:


Various properties that determine the common dialog box at
run time. They will generate the error depends on the current
value of the cancel error property.
[ Formname].CommonDialogControlName.CancelError = True.
The default is false, so that no error is reported when the
cancel button is clicked.

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.

Help dialog box:


 The final dialog box that the common dialog box control can
display a help window.
 The help window is linked to a help file that you generate.
 The common dialog box controls help dialog box can
produce the front-end dialog box your user interacts.

PRINTER DIALOG BOX:


We can print the Flag property using print method. The most
important properties dialog box.
PROPERTY DESCRIPTION
Copies Sets or return the number of copies the
user wants.
From Page, To Page Specifies what pages are wanted
LDC It is used for API
Max,Min Specifies the maximum and minimum
pages to user
Printer Default Set this TRUE and the user can click
the setup button to change the WIN.INI
file.

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.

3. Status bar control:


 The status bar control gives you a window
that you can use to display the status of the
application.
 It has the same values as the align property
for a progress for a progress bar.
 Status bar can be divided into 16 panels.
 At design time you can add the individual
panel’s page of the custom property dialog
box.

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.

4. PROGRESS BAR CONTROL:


The progress bar control is similar to using a vertical
bar control is similar to using a vertical bar in the gauge
control. It fills in a bar with rectangle chunks.

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.

CREATING AN MDI APPLICATION:-

The steps to Add an MDI Form to a project are:-


 Open a new standard EXE project.
 By default, the project contains a form named
Form1. Change the name property of Form1 to
child form1.

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

 Once the menu was added to the MDI Form,


click on the menu items in the menu bar.
 Code window will be displayed with the click
event of the menu item.

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.

WORKING WITH GRAPHICS:-


 Visual basic’s graphic image controls let you add graphics to
your applications.
 The two primary graphic image tools, the image control and
picture box control work almost exactly alike to add graphic
images to your applications.
 The tools don't give you the ability to draw lines and circles,
but you add graphic images to your applications and
manipulate those images with what you learn in this.
 Many application use toolbars with buttons that mimic menu
options. Toolbars are part of most major windows
application, and they can be part of yours as well.

12

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy