Visual Basic1

You might also like

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

(1). Explain why visual basic is known as event an object has focus. LostFocus -An object loses focus.

driven programming. List and explain about some of The user presses any mouse button while the mouse
the events supported by visual basic objects. pointer is over an object. MouseMove -The user
moves the mouse pointer over an object. MouseUp -
Ans- VISUAL BASIC is a VISUAL and Event-driven
The user releases any mouse button while the mouse
Programming Language. Each application in VB
pointer is over an object.
construct using pre-define object and each object
triggered with different event procedure and each (2). What is BCNF and 4NF? Explain with example.
procedure executes only when a programmer takes
Ans- BCNF-Boyce–Codd normal form (or BCNF or
any action against the object. In GUI based
3.5NF) is a normal form used in database
application, event is nothing but happening. Visual
normalization. It is a slightly stronger version of the
basic is Object Based Event Driven Programming
third normal form (3NF). BCNF was developed in 1974
Language as we use Objects to build our Applications
by Raymond F. Boyce and Edgar F. Codd to address
such as Text Box, Command Button on Form and it is
certain types of anomalies not dealt with by 3NF
also termed Event Driven Language because anything
we do on visual basic application such as Click Mouse If a relational schema is in BCNF then all redundancy
on command Button to implement any command, or based on functional dependency has been removed,
enter the text in text box etc. everything is an event although other types of redundancy may still exist. A
that's why we call it Object Based, Event-Driven relational schema R is in Boyce–Codd normal form if
Programming. and only if for every one of its dependencies X → Y, at
least one of the following conditions hold: X → Y is a
In BASIC, programming is done in a text-only
trivial functional dependency (Y ⊆ X), X is a super key
environment and the program is executed
for schema R. For example-
sequentially. In Visual Basic 6, programming is done in
a graphical environment. In the old BASIC, you have to
write program code for each graphical object we wish
Patient Patient Appointment Time Doctor
to display it on screen, including its position and its
No Name Id
color. However, In Visual Basic 6, we just need to drag
and drop any graphical object anywhere on the form,
and we can change its properties using the properties
window. 1 John 0 9:00 Zorro

In addition, Visual Basic 6 is Event-driven because we


need to write code in order to perform some tasks in
response to certain events. The events usually 2 Kerr 0 9:00 Killer
comprise but not limited to the user’s inputs. Some of
the events are load, click, double click, drag and drop,
pressing the keys and more. Therefore, a Visual Basic
6 Program is made up of many subprograms, each has 3 Adam 1 10:00 Zorro
its own program code, and each can be executed
independently and at the same time each can be
linked together in one way or another. That's why we
4 Robert 0 13:00 Killer
call it Object Based, Event-Driven programming //

Event - Occurs When ... Change -The user modifies


text in a combo box or text box. Click The user clicks
the primary mouse button on an object. DblClick -The 5 Zane 1 14:00 Zorro

user double-clicks the primary mouse button on an


object. DragDrop -The user drags an object to
Let consider the database extract shown above. This
another location. DragOver -The user drags an object
depicts a special dieting clinic where each patient has
over another control. GotFocus -An object receives
4 appointments. On the first they are weighed, the
focus. object has focus. KeyPress -The user presses
second they are exercised, the third their fat is
and releases a keyboard key while an object has removed by surgery, and on the fourth their mouth is
focus. KeyUp - The user releases a keyboard key while stitched closed… Not all patients need all four
appointments! If the Patient Name begins with a
Movie_Name Shooting_

Movie Name Listing Location

Movie One Comedy Movie One UK

Movie One Thriller Movie One UK

Movie Two Action Movie Two Australia

Movie Two Crime Movie Two Australia

Movie Three Drama Movie Three India

letter before “P” they get a morning appointment, <Movie_Listing>


otherwise they get an afternoon appointment.
Appointment 1 is either 09:00 or 13:00, appointment 2 (3).What is Active X control?Give an example.Describe
about Active X data controls.
10:00 or 14:00, and so on.

4NF-Fourth normal form (4NF) is a normal form ANS-All the controls, which are added to the toolbox
used in database normalization. Introduced by externally, are known as Active – X Controls. There are
Ronald Fagin in 1977, 4NF is the next level of several controls available in the Visual Basic, which
normalization after Boyce–Codd normal form exist in the ―component‖ option of ―project‖ menu.
We can use any controls according to our need. The
(BCNF). Whereas the second, third, and Boyce– Active –X controls are categorized into three categories:
Codd normal forms are concerned with functional 1.”.ctl” 2.”.ocx” 3.”.dll” 1. “.ctl”: -It is created by the
dependencies, 4NF is concerned with a more programmer. 2. “.ocx”: - All the controls, which exist
general type of dependency known as a in the “component‖” option, are in the “.ocx” 3. “.dll”:
multivalued dependency. A table is in 4NF if and - The extension of class Module file is “.dll‖.”
only if, for every one of its non-trivial multivalued
dependencies X, X is a super key—that is, X is ActiveX is one of the major technologies used in
either a candidate key or a superset . EXAMPLE- component-based software engineering.[4] Compared
<Movie> with JavaBeans, ActiveX supports more programming
languages, but JavaBeans supports more platforms.[5]
Movie_Name Shooting_Location Listing ActiveX is supported in many rapid application
development technologies, such as Active Template
Library, Delphi, JavaBeans, Microsoft Foundation
MovieOne UK Comedy Class Library, Qt, Visual Basic, Windows Forms and
wxWidgets, to enable application developers to embed
ActiveX controls into their products.
MovieOne UK Thriller Many Microsoft Windows applications—including
many of those from Microsoft itself, such as Internet
Explorer, Microsoft Office, Microsoft Visual Studio,
MovieTwo Australia Action and Windows Media Player—use ActiveX controls to
build their feature-set and also encapsulate their own
functionality as ActiveX controls which can then be
MovieTwo Australia Crime embedded into other applications. Internet Explorer also
allows the embedding of ActiveX controls in web
pages. Example 1: Building to an OCX binary
MovieThree India Drama Example 2: Building as part of an EXE project.
Example 3: Building either of the above helped by the
ActiveX Control Wizard Interface. *Brief explanation
The above is not in 4NF, since * More than one of example 1: To build an ActiveX control from scratch
movie can have the same listing.*Many shooting and compile it so that it is usable as a command button
locations can have the same movie. Let us convert or a list box is in other projects, you write the ActiveX
Control and then compile it to an OCX file. The ocx file
the above table in 4NF −
contains only the user controls that were part of the VB
<Movie Shooting> project you built it from and no extra stuff like forms or
full programs. Think of simply having a library with
button and a list box in it, that would be the same idea.
The advantage of this is that you can conveniently add End Sub
it to any VB program you may start up from the
components list. The disadvantage is that you can do Private Sub UserControl_Resize()
this only provided that the machine you're working on
(1) has that ocx file and (2) that ocx file is registered on Command1.Width = UserControl.Width
the machine. Now let's go through building this thing
Command1.Height = UserControl.Height
from scratch. *1. Startup Visual Basic 6.0. *2. On the
opening dialog box, choose ActiveX Control and hit
Open. *3. We get what looks like a blank grey End Sub. // .ActiveX data control/objects:- In
background, that's the surface of control. As we design computing, Microsoft's ActiveX Data Objects (ADO)
that surface is how it will look when we draw it on a comprises a set of Component Object Model (COM)
form later . For now, all we need to do is add a command objects for accessing data sources. A part of MDAC
button to the control, and make sure it's in the very top (Microsoft Data Access Components), it provides a
left hand corner of the User Control surface. *4. The middleware layer between programming languages and
code for this is quite simple, and I'll go through it from OLE DB (a means of accessing data stores, whether
top to bottom. There are two events we're going to databases or not, in a uniform manner). ADO allows a
provide to people using this control, so we declare them developer to write programs that access data without
as such. The thing to note is that the Click event has no knowing how the database is implemented; developers
parameters (ie the idea is that it provides no information must be aware of the database for connection only. No
to someone using this control beyond that a "click" was knowledge of SQL is required to access a database
fired) and that the MouseDown event has four when using ADO, although one can use ADO to execute
parameter. HERE ARE SOME EVENTS SQL commands. Microsoft introduced ADO in
October 1996, positioning the software as a successor to
*Event Click() *Event MouseDown(Button As Integer, Microsoft's earlier object layers for accessing data
Shift As Integer, X As Single, Y As Single). sources, including RDO (Remote Data Objects) and
*5. The next section of code deals with the one property DAO. ADO is made up of four collections and twelve
our button control will support, it's called Caption. To objects. ADO collections:- Fields---This collection
be able to read and write properties to a control, you contains a set of Field objects. The Collection can be
have to provide a Get and a Let function. There is also used in either a Recordset object or in a Record object.
a Set function which can be used for complex objects In a Recordset object, each of the Field objects that
instead of just simple data types The basic idea of these make up the Fields collection corresponds to a column
functions is that the let takes in a new string and just in that Record set object. In a Record object, a Field can
assigns it to the Caption property of the command be an absolute or relative URL that points into a tree-
button and the let just returns the current string found in structured namespace (used for semi-structured data
the Caption property of the command button.HERE providers like the Microsoft OLE DB Provider for
ARE SOME PROPERTIES Internet Publishing) or as a reference to the default
Stream object associated with that Record object.
Property Get Caption() As String Properties- An object can have more than one Property
object, which are contained in the object's Properties
Caption= Command1.Caption collection.Parameters--A Command object can have
several Parameter commands to change its predefined
End Property behaviour, and each of the Parameter objects are
contained in the Command object's Parameters
Property Let Caption(newCap As String) collection. Errors:-All provider-created errors are
passed to a collection of Error objects, while the Errors
Command1.Caption = newCap collection itself is contained in a Connection object.
When an ADO operation creates an error, the collection
End Property* 6.The next two subs are just some stuff is cleared and a new group of Error objects is created in
associated with the UserControl object. Similar to a the collection. ADO objects are following:-
Form in VB, a UserControl has a life and a death and a Connection-. Command-.Recordset Immediate-
bunch of events and methods associated with that .Batch-. Transaction- Record- Stream -Parameter-
progression. In actuality, you have as much control over Field -Property -Error.
your user control as you do over a form in VB. Here's
an example of a couple of these events being used to (4) Define Array- An array is a group of related data
resize the button to be the size the developer draws the element, that share a common name, type and scope.
UserControl to and to set the initial caption of the button An array can hold similar types of values in contigious
HERE ARE SOME USERCONTROL HANDLERS memory location. The value which is stored in an array
Private Sub UserControl_Initialize() is called Array element. Each element of the array is
stored at the specific index number or position. So the
Command1.Caption = UserControl.Name value of an array can be access with an array name and
unique index number. The 1 st element of the list is
stored at index declared as size of array, that means the Dim | Private | Public | Static arrayname (No. of layer,
lower bound of an array starts from Zero or as be specify No. of row, No. of column as datatype) // EG- Public
in the declaration and the upper bound of last index of No. (3,2,4) as single. (4) To declare 3D dynamic array
an array we find as the size of the array. // Dim | Private |Public |Static arrayname (, ,) as
datatype.(5) To allocate memory dynamically at
Array is subscript variable. In V.B ordinary variable can procedure level //Redim arrayname (Var for no. of
store only one value at a time but whan we handle a layer,var for no. of rows, var for no. of columns).
problem which requires to store and manipulate more Creation of Dynamic Arrays in Visual Basic-With a
than one value then always declare moe than one dynamic array, we can discard the data and return the
variable within the application, which may cause resources it occupied to the system. //To create a
problem to memorize each variable. Features of an dynamic array, declare it as usual with the Dim
array- (1) A group of value stored in memory with a statement (or Public or Private), but don’t specify its
common name.(2). Each element of the array identify dimensions.// Dim DynArray as Integer // Later in the
uniquically.(3). The value of an array can be access in program, when we know how many elements we want
any order from start to end or from end to beginning.(4) to store in the array, use the ReDim statement to
The elements of an array can be arranged in ascending redimension the array, this time to its actual size. In the
or descending order or in reverse or reverse alphabetical following example, UserCount is a user-entered value.//
order.(5).Array declared like simple variable with ReDim DynArray(UserCount) // The ReDim statement
datatype and scope.(6). An array may be declared as can appear only in a procedure. Unlike the Dim
basic data type, user defined type and control type. (7) statement, ReDim is executable— it forces the
Array can be declared statically and dynamically. (8). application to carry out an action at runtime. Dim
The subscript number cannot be used without statements aren’t executable, and they can appear
declaration of array. TYPES OF ARRAY- outside procedure.// A dynamic array also can be
redimensioned to multiple dimensions. Declare it with
(1) Single Dimension Array (2) Multi Dimension the Dim statement outside any procedure, as follows:
Array (1) A list of sets of elements share a common //Dim Matrix() As Double. // Then use the ReDim
name using only one subscript is called Single statement in a procedure to declare a three-dimensional
Dimension Array Bydefault Lower bond or Lower array. //ReDim Matrix(9, 9, 9).
pocket of S.D.A start from zero and upper bound as we
declare maximum size of the array. The lower bound (5) OPERATORS- The operator is a symbol which
can be start at index one using option base 1 statement. tells a computer to perform arithmetic operation and
The lowerbound may be change as we decide in the take any logical decision on their operands and produce
declaration. It uses the following syntax for declaration. desire result that means operator used within expression
as programming statement. So operator manipulates the
(a)Syntax-To declare single dimension static array value of a variable used within an expression and
(fixed size array).//Private|Public|Static|Dim produce different result. // An operator is a code
arrayname(size) as datatype. (b)Syntax-To declare element that performs an operation on one or more code
single dimension elements that hold values. Value elements include
dynamicarray.//Private|Public|Static|Dim arrayname() variables, constants, literals, properties, returns from
as datatype.(c)Syntax- To allocate memory as run time Function and Operator procedures, and expressions. //
for dynamic single dimension array.//Redim arrayname An expression is a series of value elements combined
(no. of packets) . // (2) In visual basic, a with operators, which yields a new value. The operators
multidimensional array is an array that contains more act on the value elements by performing calculations,
than one dimension to represent the elements in a comparisons, or other operations.
tabular format like rows and columns.// In visual
basic, multidimensional arrays can support either two or Types of Operators –(1) Arithmetic Operators
three-dimensional series. To create multi-dimensional perform familiar calculations on numeric values,
arrays, we need to use comma (,) separator inside of the including shifting their bit patterns. // Comparison
brackets. // Multidimensional Arrays can be declared by Operators compare two operands which may be a
specifying the data type of an elements followed by the variable or constant and after comparison returns logical
brackets () with comma (,) separator. we can initialize value 1 for true and 0 for false expressions and return a
arrays upon declaration.//Syntax- (1)To declare double Boolean value representing the result of the
dimension fixed sized array // Dim | Private |Public comparison. // Concatenation Operators join multiple
|Static arrayname (no. of rows,no.of columns as strings into a single string.// Logical and Bitwise
datatype) // EG- Dim rec(2,3) as long //(2) Syntax- *To Operators in Visual Basic combine Boolean or
declare double dimension dynamic array // Dim |Private numeric values and return a result of the same data type
|Public |Static arrayname (,)as datatype //* allocates as the values.It generally used with relation expression.
memory at run time using statement at procedural Such as logical NOT operator uses single relational
level.// Redim arrayname (var for no. of row ,variable expression and change the value true or false to false to
for no. of column).// (3) Syntax- To declare 3D array // true but logical AND, OR, XOR, Equivalednce and
Implication always uses two relational expression as date and time information. Thus for example:
operand and finally returns logical value True or False. Format(Now(), "ddd dd/mm/yy") delivers: Tue
05/03/02. A number can be added to Now( ) to give a
(6) CONTROL ARRAY- Control Array is a group of future date. Thus Format(Now( ) + 1, "ddd dd/mm/yy")
controls that shares same type and event procedure or delivers: Wed 06/03/02. // The strings "dd", "mm",
code.Like general array number of pockets for a control "yy", "yyyy", are used to represent formats for days,
array depends on hardware resources or computer’s months and years. The strings "ddd", "dddd", "mmm",
memory pernel. A control array cam be designed at "mmmm" represent short or long text formats for days
designed time & run time. At designed time control and months. These can be used within the Format( )
array can be create after creating an object of any function.
control on the form. After creating an object of a control
select the object and copy the object in clipboard and (7) Different datatypes available in VB with
after that paste the object on the form. This action example-Datatype refers type of value and range of
displays a confirmation message -Are you sure. Do you value which is going to be represent by an identifier.
want to create an object of existing control then press computers memory or within a program . Visual Basic
yes. This action delete control array with different classifies the data types in two major categories:- (1).
index. And the existing object automatically assigned Numeric Data Types (2).Non-Numeric data types. (1).
the zero index Thus repeat the same procedure to create Numeric data types are types of data that consist of
the control array with different Index. /// Control numbers, which can be computed mathematically with
array can also be create at runtime by load method. A various standard operators such as add, minus, multiply,
load method create control array of an existing object in divide and more. Examples of numeric data types are
computer’s memory with visible property false. Then examination marks, height, weight, the number of
user responsible to visualize the control array by setting students in a class, share values, price of goods, monthly
its visible property True. And also ensure the position bills, fees and others. In Visual Basic, numeric data are
of the form. We can create different control array of an divided into 7 types, depending on the range of values
object and ensure the position of the column with its they can store. Calculations that only involve round
visibility and then write common code within an given figures or data that does not need precision can use
procedure and utilize within an application with visual Integer or Long integer in the computation. Programs
interface that can control array having the following that require high precision calculation need to use
application- (1) A control array share the same name Single and Double decision data types, they are also
of an object.(2) A control array must have same type. called floating point numbers. For currency calculation
(3) Name of control array shared the name with we can use the currency data types. Lastly, if even more
different index. (4) A control array shared the code for precision is required to perform calculations that
an event procedure. (5) A control array an be create at involve a many decimal points, we can use the decimal
run time as much as requirement , and can be delete or data types. Numeric data types are as follows-Byte,
load when they are no further needed. (6) Creation of Integer, Long, Single, Double, Currency, Double. (2)
dynamic control array utilize compuer resources Non-numeric data types are data that cannot be
efficiently and improve the efficiency of the program. manipulated mathematically using standard arithmetic
(7) Unload method delete the control array which is operators. The non-numeric data comprise text or string
designed at runtime when they are further designed. So data types, the Date data types, the Boolean data types
the space on the form can be utilize for other object that store only two values (true or false), Object data
according to application requirement. (8). A better type and Variant data type. Nonnumeric data types are
utilization of form window interface is possible can be as follows- String(fixed length), String(variable
dynamic control array. (9). Control array is applicable length),date,Boolean,object,variant(numeric),variant(te
for validation when we feed data with validation for xt).
different records. (10) Data entry form with validation
can be created using control array. (11). Control array (8) Error Handling Techniques In Visual Basic-Error
save time in application development. Save memory by handling is an essential procedure in Visual Basic
avoiding repetition of code and improve the efficiency programming because it can help make the program
of program. (12). Control array is applicable to design error-free. An error-free program can run smoothly and
toolbar, to design menu control array and for animation efficiently, and the user does not have to face all sorts
program. EXAMPLE -- Use of the Date The date of problems such as program crash or system hang. //
can be stored as a string variable using the usual Errors often occur due to incorrect input from the user.
separators of / or - between day, month and year. For example, the user might make the mistake of
DateValue(string) is a function that returns a date in the attempting to ask the computer to divide a number by
form indicated by this example: 05/Apr/02 There are a zero which will definitely cause a system error. Another
number of other functions that process date information. example is the user might enter a text (string) to a box
The function Now( ) delivers the date and time: that is designed to handle only numeric values such as
05/Mar/02 09:56:22 This can be used with the the weight of a person, the computer will not be able to
Format(expression,string) function to deliver part of perform an arithmetic calculation for text, therefore will
create an error. These errors are known as synchronous Tool bar: – The tool bars gives us quick access to
errors. // There are three main types of errors that could commonly used menu command. Beside the main tool
occur while application is being used: // Syntax bar, which is displays by default window the menu bar,
Errors: A syntax error comes from your mistyping a visual basic IDE provides additional tool bar for
word or forming a bad expression in your code. It could specific purpose. The four built in tool bar are standard,
be that you misspelled a keyword such as ByVel instead edit, debug and from editor. By default, standard tool
of ByVal. It could also be a bad expression. Examples bar appear immediately below the menu bar.Project
are: 524+ + 62.55 // if Number = =2 Number = 6 // explorer: – The docked on the right side of the screen
Run-Time Errors: After all syntax errors have been and just below standard tool bar, is the project explorer
fixed, the program may be ready for the user. The time window. The project explorer window. Serve as a quick
period a person is using an application is called run- reference to the various element of a project namely
time. There are different types of problems that a user form, class and module. All the objects that make up the
may face when interacting with your program. For application are packet in a project. // The
example, imagine that, in code, we indicate that a project explorer window holds the file name for the file
picture would be loaded and displayed to the user but included in our project. A window’s title bar holds the
you forget to ship the picture or the directory of the name our project with .VBP file extension, which is
picture indicated in your code becomes different when project one by default until we save it with a new name.
a user opens your application. In this case, when we A simple project typical contents one form, which is
compiled and executed the application in machine, window that is designed as part of the program
everything was fine. This is a type of run-time error. // interface. It is possible to develop any number of forms
Run-time errors are mostly easy to fix because we will in a program. Tool box: – The tool box contains the icon
know what the problem is occurring and why. // of the control we can place on a form to create the
Logic Errors: These are errors that don't fit in any of application’s user interface. By default tool box
the above categories. They could be caused by the user contains a pointer icon and twenty other icon of
misusing your application, a problem with the computer ActiveX controls. The tool box appear at the left side on
on which the application is running while the same screen by default. User can change its position
application is working fine in another computer. anywhere on the form. Even tool box can be turn off on
Because logic errors can be vague, they can also be screen. To place a control on a form, we first select it
difficult to fix. with a mouse and then move the mouse over the form.
When the mouse is over the form, the curser turns into
(9) Explain various components available in VB a large plus sign, and we can draw control on the form,
window, explain each about them. just as we would draw a circle using a drawing
application. The size of the circle determines the size of
Visual basic window: – A visual basic window is also the control. Properties window: – Every object has
called integrated development environment (IDE) properties associated with it. The properties window is
window. This window open when we click on standard docked under the project explorer window. The
exe icon from new project dialog box. In visual basic, a properties window allows us to assign or change
program is referred to as a project. Every visual basic properties associated with a particular object. Properties
project consists of at list two separate files called a are attributes such as size, position etc. like a form, each
project file and a form file. A project file which control has its own set of properties. Some properties
extension is .VBP and form file which extension is like width, height are common to both form and
.FRM. Project file created only one but multiple form controls. Form layout window: – The form layout
file and other type of file can also be included in a window specifies a form’s position on the screen at run
project. These files are called class module (.CLS) files, time. The form layout window appear below the
standard module (.BAS) files, resource (.RCS) file, properties window. It consist of an image representing
ActiveX control (.OCX) file and show on, thus the the screen and the form’s relative position on the screen.
development of a visual basic project involves keeping With the mouse pointer positioned over the form image,
track of several different files and accessing these file draw it to the new location. Form window: – A form
individually within visual basic environment, as window used in visual basic to create project inside the
needed. // Components of visual basic IDE window: form. A form window appear on screen just like grid of
Title bar: – A title bar is the horizontal bar located the dots inform of matrix. We can increase or decrease size
top of the screen. It includes the project name, an icon of form window according to our need. By default only
that closes visual basic at the left and icon that minimize one form window will appear on screen but more than
the group window, change the size of the group or close one form window can be open on the project window.
visual basic on right. This component common for all Out of multiple form windows, one window is called
window application.Menu bar: – The menu bar is also master window and other are called slave windows. By
common for all document window. It contents default first window automatically treated as master
command required and build an application. The main window. But user can change or select any one window
menu items have some menu items that can be chosen as a master window. Remaining window are
when needed. automatically changed to slave window. // Project
window: – Only one project window will appear on table. Add the dynaset dialog box click the add button
screen when be open visual basic window. This project to add the next record. Continue this procedure to add
window appear beside the form window. User cannot all the remaining records in the table.(12)After we have
add another project in the current project. By default added all the records in the table, click the close button
name of a project is project1 and its file name is in the dynaset dialog box. (13) Click file on the visual
project1.vbp but user can change project name as well data manager menu bar. On the file menu, click exit
as project file as needed. // Code window: – Normally button. Now we return to the visual basic form window.
code window not appear on screen because it is
automatically hidden. When we double click any (11) SQL-The SQL is one of the language developed
control in the form, a code window will open. Visual by a scientist named Edgar Frank Todd’s in 1974 but
basic code window consist of two list boxes. Both list their standaridization being performed by ISO in 1986.
boxes appear at the top of the code window. The left In 1986 the SQL initially known as SEQUEL.In Oracle
most list box is called object list box and right most list the SQL was introduced in 1998. // To work with
box is called procedure list box. SQL it is necessary to create the table and work with
different types of columns data.To work with columns
(10) What types of connectivity can be used to it is necessary to specify the datatypes and constrants
connect MS-access data base to VB form? Explain at the time of creartion of table.SQL provides
with step connectivity. mechanisms for most kinds of database manipulations.
The SQL Server DataBase Management System
Creating a database: – Before using a database on the (DBMS) that is bundled with Visual Basic takes the
form we must create a database. This database work as Relational DataBase Management Systems (RDBMS)
DAO. This database work similar to Microsoft access. like Oracle or IBM DB2.SQL is an Industrial Standard
It contains number of data field such as text, memo, language for processing relational database. // Visual
number, date/time, currency, auto number, logical and Basic uses SQL to create new recordsets. Set the data
OLE Object. // Visual data manager, application controls RecordSource property to an SQL query and
that is included with visual basic allow us to create execute a Refresh method. Visual Basic use SQL to
database. To open and create a database with visual data select fields and records from a table and join the
manager, follow the following step –(1) Start visual fields from row tables.SYNTAX- Select [ distinct ]
basic and click add-Ins on the menu bar. A list of menus FieldList From TableNames //Where
option appears, select visual data manager. (2) A visual SearchConditions //Group By FieldList // Having
data manager window will open. Click file on the menu GroupCriteria // Order By FieldList EXAMPLE-
bar, then click new on the file menu. A sub menu opens. Select * From Books // Select * From Books,
Click Microsoft access. Another sub menu opens. Click Subjects // Where Books.Subject_Code=
version 7.0 MDB. The select Microsoft access database Subjects.SubjectCode // Order By Title //
to create dialog box appear. Use the dialog box to locate Select Distinct Author from Book
a folder where we wish to save the database file. Enter
file name, visual data manager automatically saves the Types of SQL Commands
file with .MDB extension. (3)Now we will add a table
to database file. Right click in the database window. On There are five types of SQL commands: DDL,
the popup menu that appears, click new table. The table DML, DCL, TCL, and DQL, // DDL(Data
structure dialog box appears.(4) Type table name is the Definition Language) : DDL or Data Definition
table name text box. Now table is saved in .DBF file Language actually consists of the SQL
extension.(5) Click the add field button in the table commands that can be used to define the
structure dialog box. The add field dialog box will database schema. It simply deals with
appear. In the name text box, type field name and in the descriptions of the database schema and is used
type list box, select a field type. Click OK button to to create and modify the structure of database
select the field. (6)The add field dialog box still display. objects in the database.**DDL changes the
Type another field name and field type and click OK structure of the table like creating a table, deleting
button every time. (7)After adding last field, click the a table, altering a table, etc.**All the command of
close button on the add field dialog box. The table DDL are auto-committed that means it
structure dialog box reappear. In this dialog box, we can permanently save all the changes in the
edit in field structure (8).Click the build the table button database. // Examples of DDL commands:
to build the table and add it to database. The visual data Create- It is used to create the database or its
manager window should appear all screen.(9) Now we objects (like table, index, function, views, store
are ready to add data to the table. Right click the table procedure and triggers). // DROP – is used to
name entry in the data base window and select open delete objects from the database. The ‘DROP
from the popup menu.(10)Click the add button. The DATABASE’ Statement-This statement is used
Dynaset add record dialog box. Should appear on to drop an existing database. When you use this
screen. Enter the record value of each field and click statement, complete information present in the
update button.(11)Second record is now added to the database will be lost. / Syntax-DROP DATABASE
DatabaseName ; Example-DROP DATABASE analysis. Tables appear in print media,
Employee; The ‘DROP TABLE’ Statement -This handwritten notes, computer software,
statement is used to drop an existing table. When architectural ornamentation, traffic signs, and
you use this statement, complete information many other places. The precise conventions and
present in the table will be lost. / Syntax -DROP terminology for describing tables vary depending
TABLE TableName; / Example - DROP Table on the context. Further, tables differ significantly
Employee_Info; // ALTER-is used to alter the in variety, structure, flexibility, notation,
structure of the database. The ‘ALTER TABLE’ representation and use. In technical articles,
Statement - This statement is used to add, tables are typically presented apart from the main
delete, modify columns in an existing table.The text in numbered and captioned floating blocks. //
‘ALTER TABLE’ Statement with ADD/DROP A table consists of an ordered arrangement of
COLUMN- we can use the ALTER TABLE rows and columns. This is a simplified description
statement with ADD/DROP Column command of the most basic kind of table. Certain
according to need. If we wish to add a column, considerations follow from this simplified
then we will use the ADD command, and if we description: (1) the term row has several common
wish to delete a column, then we will use the synonyms (e.g., record, k-tuple, n-tuple, vector);
DROP COLUMN command. / Syntax- ALTER (2) the term column has several common
TABLE TableName // ADD ColumnName synonyms (e.g., field, parameter, property,
Datatype; / ALTER TABLE TableName / DROP attribute, stanchion); (3) a column is usually
COLUMN ColumnName; // TRUNCATE–is used identified by a name; (4) a column name can
to remove all records from a table, including all consist of a word, phrase or a numerical index; (5)
spaces allocated for the records are removed. // the intersection of a row and a column is called a
COMMENT –is used to add comments to the data cell. (6) The elements of a table may be grouped,
dictionary. // RENAME –is used to rename an segmented, or arranged in many different ways,
object existing in the database. // DQL (Data and even nested recursively. Additionally, a table
Query Language) : DML statements are used for may include metadata, annotations, a header, a
performing queries on the data within schema footer or other ancillary features. //
objects. The purpose of DQL Command is to get Characteristics of Table -A table is perceived
some schema relation based on the query passed as a two-dimensional structure composed of rows
to it. Example of DQL: SELECT – is used to and columns. (1) Each table row (also known as
retrieve data from the a database. // DML(Data tuple) represents a single instance of the entity
Manipulation Language) : The SQL commands within the entity set. (2) Each column represents
that deals with the manipulation of data present in an attribute and each column has distinct name.
the database belong to DML or Data Manipulation (3) Each row/column intersection represents a
Language and this includes most of the SQL data value. (4) Each table must have an attribute
statements. Examples of DML: /INSERT – is or combination of attributes that uniquely
used to insert data into a table. / UPDATE – is identifies each row. (5) All values in a column
used to update existing data within a table. / must confirm to the same data format. (6) Each
DELETE – is used to delete records from a column has specific range of values known as the
database table. // DCL(Data Control Language) domain of the attribute. (7) The order of rows and
: DCL includes commands such as GRANT and columns is immaterial to the DBMS. // To
REVOKE which mainly deals with the rights, illustrate the characteristics of table, we consider
permissions and other controls of the database the table of candidates at IT Bank, Inc. The table
system.Examples of DCL commands:GRANT- at present contains information on ten candidates
gives user’s access privileges to database. / (i.e., 10 rows) each having information on eight
REVOKE-withdraw user’s access privileges given attributes (i.e., 8 columns). Each row represents
by using the GRANT command.TCL(transaction one candidate a single entity occurrence within
Control Language) : TCL commands deals with the entity set. Each column represents an
the transaction within the database.Examples of attribute of candidate and that each attribute has
TCL commands:COMMIT– commits a distinct name. Each row/column intersection
Transaction. / ROLLBACK– rollbacks a contains only one data value. All the values in a
transaction in case of any error occurs. / column match entity’s characteristics.
SAVEPOINT–sets a savepoint within a
transaction. / SET TRANSACTION–specify (13) Explain different properties of control .
characteristics for the transaction.
A VB Contains a number of graphical structure in
(12)Table and its characteristics - A table is an tool box in which each and every structure having
arrangement of data in rows and columns, or their own operation. (1) LABEL – the label is one
possibly in a more complex structure. Tables are of the control that represents other control at the
widely used in communication,research, and data form interface. (2) TEXT BOX- the single lines or
multiple lines of data when need to input than
Textbox is created. (3) CHECK BOX- when
multiple options are available in which anyone of
them or more than one need to select then the
concept of check box is to be used. (5) RADIO
BUTTON -It is also known as option button when
multiple values are available in which when a
single value only be selected at a time then radio
button is being created. (6) COMBO BOX – The
combo box is one of the control that contains
multiple values, when selected all the values are
displayed but only one can be selected at a time.
(7) LIST BOX -when multiple values are stored
and displayed and selected from the list of the
values , then it is used. (8) PICTURE BOX-
Whenever a picture appeared at the form
interface then it is used. (9) IMAGE BOX -
Whenever a user need to place both the picture
and text then this particular options is used.
(10).DRIVE LIST BOX – When this control is
created then the list of drives available in the An entity–attribute-relationship diagram for a
system hard disk becomes displayed in it. (11). MMORPG using Chen's notation
Directly List Box – when the drive being selected
then their list of directories when need to display Entity–relationship modeling was developed for
then it is used. (12) FILE LIST BOX- Whenever database and design by Peter Chen and published
the directory from the directory list box need to in a 1976 paper, with variants of the idea existing
be selected then the list of file displayed in it. previously.Some ER models show super and
(13).FRAME-when multiple control of VB is subtype entities connected by generalization-
represented by a single control then it is used. specialization relationships, and an ER model can
(14). LINE – when the horizontal vertical or be used also in the specification of domain-specific
diagonal line need to be generated then it is used. ontologies.
(15). SHAPE – there are different inbuilt shapes
are available like circle, rectangle ,oval etc. (15)COMMON DIALOG BOX- (1) We can use set
When need to place on from interface then it is of predefined standard dialog boxes in your
used. (16). TIMER- When the elimination in VB projects for such tasks as specifying colors and
need to perform then this control is to be used. fonts, printing, opening and saving. The common
(17). DATA CONTROL- to connect the database dialog boxes control, which is a custom control,
with the interface of VB then it is used. // Apart allows your project to use the dialog boxes that are
from these a user can attach or remove the provided as a part of the Windows environment. //
controls from the reference or components option 2. To use the common dialog control, you first
of project menu.Every control contains three place a control, and its location doesn’t matter, you
different parts I,e property part , mtehods and can not change size of the control, since it will be
events. invisible when your program will run. //
3. In code when you wish to display one of the
(14) Entity Relationship Model-An entity– standard dialog boxes, you refer the properties and
relationship model (or ER model) describes methods of the control. // 4. You don’t need
interrelated things of interest in a specific domain more than one dialog control on your form.
of knowledge. A basic ER model is composed of
entity types (which classify the things of interest) TYPES OF DIALOG BOX - (1) Color Dialog Box:
and specifies relationships that can exist between 2. Font Dialog Box: 3. Save Dialog Box:
entities (instances of those entity types). // In
software engineering, an ER model is commonly Color Dialog Box: Visual Basic common dialog
formed to represent things a business needs to box provides Color dialog box which can be used
remember in order to perform business processes. for user to select color from the common dialog
Consequently, the ER model becomes an abstract box. You can assign the values selected by user to
data model, that defines a data or information controls in your project. This dialog box can be
structure which can be implemented in a database, used by writing a code as follows:
typically a relational database. dlgCommon.ShowColor
Font Dialog Box: Font Dialog Box allows user to Notepad: You must close one document before
select his custom font setting like, font name, font editing another. // WordPad: You must close one
size, font color, font style, strike through etc. To document before editing another. // Calculator:
display the font dialog on screen use ShowFont You can use only one calculator at a time. // In a
method of the common dialog object. // But before classic SDI program such as Notepad, if we want
using the ShowFont method you first initiate the to edit two documents at once you need to run two
flag property for font that is cdlScreenFont. instances of the program. Neither instance of
Notepad knows the other exists, and they do not
Save Dialog Box: Visual Basic even provides interact. Differences
save file dialog box which displays a save file
dialog box to get the path for file to save. MDI SDI
Can only be
Properties of Common Dialog Box- Printing, implemented
Opening files , Saving file , Choosing fonts , through special
Maximize all Maximize parent
Choosing colors // Most of these dialog controls code or through a
documents window
are found in the Dialogs section of the toolbox and window manager
like the timer and menu controls, are placed in the that can group
component tray when added to the form. // We windows
use the ShowDialog method to display a common Switch Using special
Through task
dialog box. // dlgOpenFile.ShowDialog() between interface inside
/window manager
documents parent window
(16) DYNAMIC BINDING - Dynamic binding also You can only
called dynamic dispatch is the process of linking stretch the parent
procedure call to a specific sequence of code window and try to
Multiple
(method) at run-time. It means that the code to be organize Easily done
Desktops
executed for a specific procedure call is not known individual
until run-time. Dynamic binding is also known as windows
late binding or run-time binding. // Dynamic manually
binding is an object oriented programming concept You can only
and it is related with polymorphism and span the parent
inheritance. Dynamic binding definition window and try to
Dynamic binding(dispatch) means that a block of Multiple
organize Easily done
Monitors
code executed with reference to a individual
procedure(method) call is determined at run time. windows
/// Dynamic dispatch is generally used when manually
multiple classes contain different implementations Possible only
of the same method. It provides a mechanism for Naturally
Grouping through special
selecting the function to be executed from various implemented
window managers
function alternatives at the run-time. In C++, virtual
Switch
functions are used to implement dynamic binding.
focus to Difficult to
Easily handled
specific implement
(17) MDI - A multiple-document interface (MDI) is document
a graphical user interface in which multiple
windows reside under a single parent window. (18) ORACLE - An Oracle database is a collection
Such systems often allow child windows to embed of data treated as a unit. The purpose of a
other windows inside them as well, creating database is to store and retrieve related
complex nested hierarchies. This contrasts with information. A database server is the key to solving
single-document interfaces (SDI) where all the problems of information management. In
general, a server reliably manages a large amount
windows are independent of each other.
of data in a multiuser environment so that many
users can concurrently access the same data. All
SDI - This is the simplest interface you can present
this is accomplished while delivering high
to the user. In a complicated program, however, it
performance. A database server also prevents
can also be the most confusing. // An SDI
unauthorized access and provides efficient
program requires that you close one screen before
solutions for failure recovery. // Oracle Database
opening another. There would be no way to just flip is the first database designed for enterprise grid
back and forth between screens. This is the classic
computing, the most flexible and cost effective way
definition of an SDI program. Here are some
to manage information and applications.
common examples:
Enterprise grid computing creates large pools of
industry-standard, modular storage and servers.
With this architecture, each new system can be Manufacturing It is used for the
rapidly provisioned from the pool of components. management of supply chain and for tracking
There is no need for peak workloads, because
production of items. Inventories status in
capacity can be easily added or reallocated from
the resource pools as needed. // The database warehouses.
has logical structures and physical structures.
Because the physical and logical structures are HR Management For information about
separate, the physical storage of data can be employees, salaries, payroll, deduction,
managed without affecting the access to logical generation of paychecks, etc.
storage structures.
ADVANTAGES- (1)DBMS offers a variety of
(19) DBMS - Database Management System is
techniques to store & retrieve data.(2)DBMS
a software for storing and retrieving users' data
serves as an efficient handler to balance the
while considering appropriate security
needs of multiple applications using the same
measures. It consists of a group of programs
data.(3)Uniform administration procedures for
which manipulate the database. The DBMS
data.(4) Application programmers never
accepts the request for data from an application
exposed to details of data representation and
and instructs the operating system to provide
storage.(5)A DBMS uses various powerful
the specific data. In large systems, a DBMS helps
functions to store and retrieve data
users and other third-party software to store
efficiently(6).Offers Data Integrity and
and retrieve data. // DBMS allows users to
Security.(7)The DBMS implies integrity
create their own databases as per their
constraints to get a high level of protection
requirement. The term “DBMS” includes the user
against prohibited access to data.(8).A DBMS
of the database and other application programs.
schedules concurrent access to the data in such
It provides an interface between the data and
a manner that only one user can access the
the software application.
same data at a time.(9)Reduced Application
Development Time.
Application of DBMS=

Sector Use of DBMS DISADVANTADES-(1)Cost of Hardware and


Software of a DBMS is quite high which increases
Banking For customer information, the budget of your organization.(2)Most
account activities, payments, deposits, loans, database management systems are often
etc. complex systems, so the training for users to use
the DBMS is required.(3)In some organizations,
Airlines For reservations and schedule all data is integrated into a single database
information. which can be damaged because of electric
failure or database is corrupted on the storage
Universities For student information, course media.(4)Use of the same program at a time by
registrations, colleges and grades. many users sometimes lead to the loss of some
data.(5)DBMS can't perform sophisticated
Telecommunication It helps to keep call calculations.
records, monthly bills, maintaining balances,
etc.

Finance For storing information about


stock, sales, and purchases of financial
instruments like stocks and bonds.

Sales Use for storing customer, product & sales


information.
.

You might also like