6 - Computer Systems and Applications (T.Y.B.com Sem - Vi)
6 - Computer Systems and Applications (T.Y.B.com Sem - Vi)
@ (0712)2737052
Vadodara Joshi Brother's ltishna lftupa Miradatar's Tekro,
Navabazar, Vadodara - 390001 (Gujarat). O O265-241897L I 2417287
Bhaunagar Shah & Co. High Court Road, Bharmagar (Gujarat). @ (0278\ 2576679
rsBN - 978-81-936595-5-7
@ Authors
The book is strictly written according to the new syllabus available u the time of pinting.
Every possible effort has been made to avoid enors and omissions in this publication by the Authors and the
Publishers. Inspite of this effort, some typographical errors might hove crept in. Any mistake, error or discrepancy
noted may be brought to our notice which shall be takcn care of in the forthcoming edition. It is hereby notified that
neither the Author nor thc Publishers or seller will be liable for any damage or loss to anyone, in any maruwr,
there Jrom. It is suggested that to avoid any doubt the reader should cross--check all the facts, law and contents of
the publication with original Government publication or notifications wherever applicable.
The text of this publication, or any part thereof, may not be reproduced or transmitted in any form or by any
means, electronic or mechanical, including photocopying, recording, storage in an infonnation retieval system, or
reproduced on any disc, tape, perforated media or other information storage device, etc., otherwise, without the
prior written permission of the publisher and author. No key to this book can be prepared without the prior written
permission of the Publishers. Any violation will invite prosecution legal action under the Indian Copyright Act.
This book is soW subject to the condition that it shall not by way of tradc or otherwise, be lent, resold, hired
out or circulated.
For binding mistakes, misprints or for misstng pages, etc., the publishers' liability is limited to replacement
within one month ofpurchase by similar edition. All expenses in this connecrton are to be borne by the purchaser.
All disputes are subject to jurisdiction of courts, tribunals andforums at Mumbai only.
Published & : 6heth Dubliohero Private [1d., Unit No. 4, Ground Floor,
Printed by Lalwani Industial Estate, 14, G.D. Ambekar Marg, Wadala, Mumbai - 400 031.
@ 6662 4553 I 6662 4554FAX:6662 4556.
Prcfacc
It
giues us great pleasure to present this book on the reuised sgllabus of
'computer Systems and Applications'for the students of T.Y.B.com. (Semester w)
This book is a result of a demand from th.e facultg teaching this subject as one
of us ha.s been inuolued not onlg in th.e framing of this reuised sgllabus, but also in
tle conduct of seueral utorkshops for th.e same.
An attempt hrs been made to include a large number of examples keeping in
mind the pattern of the qtestion papen Simple language h.as been used to make the
concepts uery clear.
"We ttaue also couered all the practical's in Visual Basic and Microsofi Excel, as
prescribed bg the Uniuersitg and giuen more exercises for practice".
We are thankful to Shri. Deepak Sheth, Shri. Kirit Sheth and the staff of
M/ s. Sheth Pubtishers Put. Ltd. for their sincere efforts in bringing out this book.
We hope that the students and the faaitg find this book useful. We would
appreciate constructiue suggestions uhich can be sent to [email protected] and
muke s h. te kut ani@ mail. co m
Although all care has been taken in the production of this book, a feut errors
maA haue inaduertentlg remained and the errata for this book and some
supplementary mateial for this book uill be auailable on the utebsite
wu)u).mA examnote s. com/ tgbcom. html
Fa;lyol @adlwalla
Mukcth N, Tokwanl
(iii)
Syllabas
Eleeti-os-eqryFes$C)
abAfiyfuhqaee rueLt C o ur s- e s_ ($E Q )
Modules at a Glance
1. E - Commerce 18
4. Visual Basic 09
Total 45
(v)
St.
Modules / Units
No.
1 E - Commerce
a) Definition of E-commerce
b) Feafures of E-commerce
c) Types of E-commerce (B2C B2B, C}C,P2P)
d) Business Models in E-commerce (Advertising, Subscriptiory
Transaction Fee, Sales Revenue, Affiliate Revenue)
e) Major B2C models (Portal, Etailer, Content Provider, Transaction
Broker, Market Creator, Service Provider, Community Provider).
0 E-Commerce Security: Integrity, Non repudiation, Authenticity,
Confidentiality, Privary Availability.
g) Encryption: Definition, Digital Signatures, SSL.
h) Payment Systems: Digital CastU Online stored value, Digital
accumulating balance payment, Digital credit accounts, digital
checking.
i) How an Online credit card transaction works. SET protocol.
i) Limitation of E-commerce.
k) M-commerce (Definition and Features).
b) Functions
o Database Functions LOOKUB VLOOKUP, HLOOKUP
Visual Basic
a) Introduction to Visual Basig Introduction Graphical User Interface
(GUr).
A
functiory Using If statements with Option Buttons & Check Boxes.
Msgbox (Message box) statement Input Validation : Is Numeric
function.
i) Sub-procedures and Sub-functions, Using common dialog box,
Creating a new sub-procedure, Writing a Function procedure. Simple
loops using For Next statements and Do while statement and display
output using MsgBox Statement.
Nofr';
a) Theory l3lectures per week.
b) Practicalbatch size 20-25,01 practical = 03 theory leitures per week.
c) 10 Practical's are to be completed in each semester.
Semester VI
Topic Number of Practical's
Presentation skills 01
(viii)
9. Write a project in VB to design a suitable form to enter sales and calculate and
display the bonus which is10% of sales.
L0. Write a project in VB to design a suitable form to enter salary and calculate
and display the DA which is90% of salary.
Scheme of Examination
Q.2. I 15 30
Q.3. II 15 30
Q.4. UI 15 30
Q. s. IV 15 30
02 Introduction to VB Programing 03
03 Journal 05
04 Viva 05
(ix)
\
Practical examination to be conducted 2 to 3 weeks before the theory
examination. Marks out of 25 to be submitted to the University before
commencement of theory examination.
Software Requirement :
(x)
Contcnts
MODUTE I I E.COMMERCE
1. E-Commerce 1-6
2. 'Ilpes of E-Commerce andBusiness Models 7-13
3. E-Commerce Securit5r t4-24
Practicals t8l-244
Viva 245-254
(xi)
b
ALL OUR BOOKS AVAILABLE AT
BOOKSTORE CONTACT BOOKSTORE CONTACT
NO. NO.
Lakhani Book Depot, Charni Road. 238543s6 Prabhat Stores, Kurla. 25227693
Students'Book Depot, Chami Road. 23853708 Jayesh Book Centre, Chembur (E). 25285416
Vidyarthi Book Depot Charni Road. 23858828 Nandu Book Cenfre, Chembur. 252t1441
Winner Book Depot Chowpatty. 23641307 Social Book Centre, Vidyavihar (E). 21027362
Mazgaon Book Depol Mazgaon. 23722081 Varsha Book Centre, Vidyavihar 32612537
Navjivan Book Cenhe, Bandra (W). 2il22157 Shah Book Depot Ghatkopar (W). 25156319
Goklesh Book Centre, Khar Road (W). 2il98981 Lata Book Depot, Vikhroli. 25749289
Parle Book Centre, Vile Parle (W). 26188389 Raj Book Depot, Bhandup. 259495t1
Vijay Book Cenhe, Vile Parle (W). 992090667t Jagdish Book Depot, Mulund (W). 9867281381
2610 t743
Parle Book Depot, Vile Parle (E). 26145984 Pooja Book Depot Mulund (W). 89704083 l0/
92244 98677
The Book Shop, Vile Parle (E). 26t82420t Sonal Book Depo! Mulund (E). 256422t0
2612 399r
Book Point Andheri (W). 9892106828 Jagdish Book Depot Thane (W). 98692127s9
Books Emporium, Andheri (E). 28203894 Laxmi Book Depot, Thane (W). 25367371
Santosh Book Depot Goregaon (W). 28766126 Saraswati Book Depot, Thane (W). 25367777
Thakur College Book Centre, 2885 1540 Bagade Stores, Kalyan (W). o25t-2204280
Kandivali (W).
Parshva Book Centre, Kandivali (W). 28076628 New Alankar Book Depot, Kalyan(W). 992055316t
Good Luck Stores, Mira Road. 9819816487 Hira Book Sellers, Ulhasnagar. 02st-2569521
Bhavik Book CenEe, Vasai Road (W). 02s0-2334280 Student Book Store, Vashi. 27662724
Ambika Book Cente, Vasai Road (W). 9270902323 Bhavesh Book Stall, Kopar Khairane. 27547616
Bhavik Book Depot Virar (W). 9270902323 Sai Book Depot, Airoli. 9769760CI97
Gandhi Stationery, Boisar (W). 02525-253935 Ganesh Book Depot Nerul. 27700531
Madhu Book Depot, Matunga (CR). 9324216999 Krishna Book Stores, Kharghar. 27744962
Shanti Book Store, Matunga (CR). . 24010275 Krishna Book Centre, Kharghar. 27749988
S.K. Book Stall, Sion (W). 240/.5605 Shree Narayan Stores, Panvel. 27454767
Navrang Books & General Stores, 8087983529/ Students' Agencies (D Pvt. LTE., 4M9 6t6U
Ambemath. 9764746986 Tardeo. 9167290777
GAJANAND Kmpa Enterprises, Vasai. 0250- Ambika Book Centre, Vasai. 0250 -2331365
2333s92t
9923669626
ANbHERI Book Depo! Andheri. 2683M32t Anjali Book Centre, Andheri. 26356618 /
28324126 28719025
Anjali Book Cenhe, Andheri. 263566181 College Book Cenfe, Vile Parle. 26707393
28719025
Maru Book Cenne, Kandivli. 28072124 Shree Ganesh Book Centre, Borivli. 28051251
Ambika Book Depot, Kandivli. 2846/073 Shanti Book Depot Bhayander. 2814713s
Shweta Book Depot, Kandivli. 9920998776 Shree Laxmi Stores, Bhayander. 9819260262
Milan Book Depot Vidyavihar. 9833 198030 Agrawal Book Depot Goregaon. 8760321
Bhavesh Stores, Borivli. 7710995974 New Jay Ambe Book D.pot, 0251 -24867251
Dombivli. 256173341
92233062s8
Kiran Stores, Silvassa. 9825545250 Jatin Traders, Nerul. 27726799
Shri Ganesh Book Depot, Nerul. 2770053u Ganesh Book Stores, Vashi. 276560841
27718627 27661809
Glory Book Cenhe, Nerul. 2772286 Prakash Novelty & Book Depot 27700859
Nerul.
College Book Centre, Kharghar. 99876447181
993076/.748
DCommerce t"r"l," 1
ODULE I
-COMMERC
I E-Commerce
INTRODUCTION
In the late 1970s, technologr such as Electronic Data Interchange (EDI) and
Electronic Funds Transfer (EFT) were used for doing commercial transactions
electronically. Now businesses could send commercial documents like purchase
orders or invoices electronically
The growth and acceptance of credit cards, automated teller machines (ATM)
and telephone banking in the 1980's was another form of Electronic Commerce.
In 199O, the World Wide Web was invented by Tim Berners-Lee. By the end of
2O0O many companies in America were offering their business services through
the internet.
Deflnltloa
/' of E-Commerce
I Electronic Commerce is a process of doing business electronically, using
infoYmation and communication technolory. Hence all digita[y enabled
commercial transactions between and among organizations and individuals is
covered under E-Commerce.
Simple examples of E-Commerce include buying and selling of 'various
products on the internet, such as movie and music CD's and DVD's, clothes,
books, software, cars, movie tickets, as well as making various reserwations in
airlines, railways, hotels etc.
There are many different delinitions of E-Commerce and each author has
defined it as perceived by him/her for its usefulness. However, the one given
above is the most popular among them.
FEATURES OF E.COMMERCE
The important features of E-Commerce as listed below :
Ilbtqutty
When we say that E-Commerce is ubiquitous, it means that it is available
just about ever5nnrhere and at any time. It removes tJ:e boundaries of space and
makes it possible to shop from the conflnes of your home or office and even when
travelling by various modes of transport. It removes several restrictions that are
normally associated with commerce, of having to spend time and money
travelling to the market place where you have to make your purchases. Hence it
liberates the market from any physical space that we normally associate with
carrying out commerce.
2 fc;f i CotryruterSystems andApplications-T.Y.B.Com.-(Sem.Vl)
Global Reach
E-Commerce technolosl pennits commercial transactions to cross various
cultural boundaries, as well as the geographical boundaries that have been made
by mankind across the globe. Hence the size of the market that is available for
E-Commerce includes the entire population which is going online. F\rrther with
more and more persons using computers and the internet, this number is going
to keep growing..The reach of tl:is market is globat and is continuously growing.
Universal Standards
The technical standards used in E-Commerce are universal standards
i.e. they are used all over the world. This is chiefly due to the fact that the
technical standards used in the internet are universal standards, which are
accepted and shared all over the world.
The use of these universal standards in E-Commerce has resulted in a great
reduction in the costs involved in searching for products, as tJrey can be viewed
by one and all. The suppliers of various products and their prices are located
easily without any technological barriers.
Interactlvity
The technologies used in E-Commerce are interactive i.e. they allow a two
way communication between the parties involved in the transaction, which are
the merchant making the sale and the buyer. For example, a website may ask the
consumer to fill in a form and depending on the data entered in that form,
various options are displayed, from which the consumer can choose the
appropriate one. Also online chatting has become a very popular means of such
communication which assist in E-Commerce. This two way communication is not
possible in various other technologies with the exception of the telephone.
Rlchness
Richness refers to the complexity and content of information on a product,
which is traded in E-Commerce. Using audio and video the richness of the
information that is given is greatly enhanced. This, in turn, becomes a powerfrrl
tool for selling in the commercial environment. Various products on display and
sale on the internet can be more effectively marketed, because of the richness of
the content of the website where this information is available.
Informatlon Denslt5r
Information density refers to the total amount and quality of information that
is available to all the stakeholders (market participants, consumers and
merchants). The wide use of E-Commerce has greatly reduced the cost of
collection of information, its storage, processing and communication. Further the
information available is more accurate as it is updated regularly. Today
information available is of better quality and is more plentiful.
Personallsation
This enables the merchants and traders to have better information of the
requirements in the market, due to which they can modi$ their marketing
strategies. Due to the interactive nature of technologr used in E-Commerce, the
past preferences and behaviour of the user is known. This enables merchants to
customize i.e. give the product or service as desired by the user.
This information also enables the merchants to divide the market into a
number of subgroups with a brand targeting each subgroup and charge premium
prices where high qualit5r of service is provided.
E-Commerce l,'lr't' 3
ELEMENTS OF E.COMMERCE
The elements mentioned below are normally present in any E-Commerce
transaction :
1. A product or service.
2. A website, which is the place where the business transaction takes place
and where the products and services being offered are displayed.
3. Means for visiting the website i.e. through the internet.
4. Method of accepting the orders by filling of an online order form.
5. Payment methodologr, which can be using credit cards or online
payments through direct debit etc.
6. Delivery methods to send the product to the customer. Normally third
parties are also involved in ensuring timely delivery of the products. In
case of games and software direct download is also available.
7. Facility to handle goods which are rejected and returned by the customer.
8. Means for handling warrant5r claims.
9. A follow up mechanism as a customer service, which will take care of FAQ
etc.
SCOPE OF E.COMMERCE
The scope of E-Commerce is extremely wide as it encompasses the globe. It
involves the staff and management of an organization , the suppliers, the traders,
the distributors and the entire infrastructure maintaining and keeping the
website updated at all times. The three main areas of application of E-Commerce
are listed below :
1. Electroalc Markete
It is a virfual representation of tl'e physical markets. that we are used to
seeing around us. It uses information and communication technologr to
showcase the various products being sold before the customers. It is here that
trading is done on the internet.
2. Elcctronic Data Interchange : (EDI|
' Electronic Data Interchange is a computer to computer exchange of
structured information which is given in a standard format, which can be directly
received and processed on computers. Sales invoices, Sales orders, Bills of lading
and many other documents are directly sent from one entit5r's computer to
another. To make EDI work one needs communications soffware, translation
software and access to standards.
Working of EDI
EDI works on the basis of the following three steps :
1. The data to be sent directly to the computer of the trading partner is first
converted into a standard format (called mapping) using a translation
software. There are specific standards for invoices, purchase orders etc.
2. This standard format is then sent over communication lines to the trading
partner's computer. For this the communication software is used.
3. At the trading partner's end, the format is re-translated using the
translation software.
Advantages of EDI
1. Orders are received faster.
2. Faster response from the trader.
2/T.Y.B.Com - Com. Sys. & Appl. (Sem. - V!
4 Jr't'3|' Computer Syslems and Applications - T-Y.B.Com.-(Sem. VI)
2. Security : The main issue before the customers is regarding theft of their
credit card numbers. Due to this there is reluctance among many
customers to buy online.
3. System and Data Integrity : The protection of data and the integrity of
the system that handles this data is a matter of serious concern. There
are a number of viruses that are rampant today and new viruses are
being encountered on a regular basis. These viruses cause unnecessary
delays, storage problems and there is always the danger of hackers
corrupting data in the system.
4. Expenslve to Maintain A Scalable Webslte : When a merchant puts up
a website for E-Commerce, he has a basic notion of the number of
persons that will visit his website. If twenty thousand are expected to visit
the site and one lakh do so there will be degradation and slowdown and
hence loss of customers. To avoid this there *iii harr. to be a constant
review of the number of visitors to the website and up gradation will have
to be done where necessary. This takes some effort and involves a cost
that needs to be kept in mind.
5. Fulfillment Problems : During peak periods like Diwali or Christmas
there may be a larger number of orders placed than the merchants
system can handle. This causes delay in the shipping of goods to the
customers, leading to a host of cancellations of orders, as products that
were needed at a particular point of time would not have the same value if
delivered after the festival is over.
5. Corporate Vulnerability : As all details of the merchant, namely the
products that are being offered, their catalogues, as well as other
business offers would be easily available to competitors, the larger
merchants may force them to work with very low margins due to more
competitive pricing. This would drive away an alternative source of
purchase for a consumer.
7. Technological Limltations : Today in a developing societ5r not all
persons have access to the internet nor do they have credit cards to carry
out transactions. This creates limitations in the scope of E-Commerce.
oBJECTTVE QUESTTONS
I. Answer which of the following are true or false?
1. The scope of E-Commerce is local..
2. EDI requires a invoice
3. E-Commerce is available 24 x 7.
4. E-Commerce means buying and selling of products or services by business or
consumers over the internet.
5. Trade cycle in E-Commerce is the sarne as in traditional commerce.
6. EDI is a part of E-Commerce
7. E - Market is a subset of E-Commerce.
8. E-Commerce is global.
il. Multiple Choice Questions
Select the approprlate optlon from the followlng :
1. Buying and selling products on the internet is called
a) EDI b) E-Commerce
c) E- Business d) E market
2. EDI stands for
a) Electronic Data Information b) Electronic Data Interchange
c) Electronic Data Interface d) Electronic Data Inference.
6 t'r'g' Computer Systems andApplbatbns-T.Y.B.Com.-(Sem.Vl)
3. E-Commerce means
a) Buying and selling b) Buying and selling over the internet
c) Accounting on the internet d) None of these
4 A computer to computer exchange of business transactions is called
a) E-Commerce b) E -Business
c) EDI d) E - Market
|axswERsl
I. [True i 3,4,5,6,7,8]
False z 1,21
r. l(1 - b)l (2 - b)l (3 - b)l (4 - c)I
QUESTTONS
1. What is E-Commerce?
2. What are the advantages and limitations of E-Commerce?
3. What is the difference between E-Commerce and E-Business?
4. Mention the elements of E-Commerce.
5. What is the scope of E-Commerce?
6. Explain the term EDI.
7. What are the advantages of EDI?
8. What are the features of E-Commerce?
r?'r'
Tgpes of E-Commerce andBusiness Models g't,'t,'
Traditional forms of commerce have been in existence for decades and will
continue to do so. However due to the various advantages of E-Commerce listed
in the previous chapter, the trend to use E-Commerce has been increasing and is
bound to continue to do so. There are different types of E-Commerce and this
distinction is by the nature of the relationship i.e. the parties involved in the
buying and selling. The types of E-Commerce are :
i) Business - to - Consumer (B2C)
ii) Business - to - Business (B2B)
iii) Consumer - to - Consumer (C2C), Peer - to - Peer (P2P)
This refers to the sale of products and services from a firm or company to the
consumer. It is one of the largest forms of E-Commerce. It covers businesses
which sell their products directly to the consumer over the internet.
The most common examples are shopping, entertainment, travel etc. The
more common B2C E-Commerce examples are various online retailing companies
such as Amazon.com, drugstore.com, Barnes and Noble, toysRus etc. It is
estimated that the world wide B2C E-Commerce revenues had crossed US $425
billion rrr2OO4.
The general idea in B2C E-Commerce is to have access to more customers
and give them better services. This generates more sales and less expenditure is
incurred while doing so.
More and more persons are shifting to B2C E-Commerce, as instead of
rubbing shoulders with crowds at malls and supermarkets, one can visit the on-
line shopping malls from the comfort of your home and have the goods
conveniently delivered at your doorstep.
8 t't't,' Computer Sgstems and Applications - T.Y.B.Com.-(Sem. VI)
Soobr*- nsiE -
g r*iu I S $ :ueesa snc - ..] sd $re G"rlcry -
& - E - i.t di , p.e.. H.y- Id- O- "
,sclt@m 'g olm I mrw H,Goesl
Cto6e to &{ay or g/n *am cdt tagtzo af 1Q{,9r0 and mrc g$ducts - dalivery at yaut doorstsq'
Sbarch
REnt, rokl i
Psler
shin @40!6
C.:6ts
Rs.299
EnCdd Write
861 *[aqg
of
n Addrc
g9n
R+{95
8.8
Perfume Fd lllf,lliHl :'ry,Effib
1|l ,m
f[,w***,
U-rra.db.ck
e E,xrfgdFa*gdiue,dqui*dw.l
I'it
ffiH0ll
gotWqnqMh$M
sto[3
EWffi
gqslx..
YE-lldgil 5iiru stury.
$ cffiryh24mlb.Flre. ffi6,
CtrffistHmpG
Ik td
ABt{, Pffi Engae4
Eryl0nro Brnda ts Cl[slrtLeetups&mnrffie
S,at edADpaeb
Wls.
-
]NTffiWdOB,U,W rGwdi[ffioe.r4,rc y
WlMMQba,m u*!6rIEfrnrelEB.3,3B IIr d.y ry drfld .r.Xs fie @t h. !16l
On
fnli.. !h.Fpi|r 3l
arrd.f or products. Such websites are popular and hence become a good place for
any business to advertise their products and get noticed.
When the user clicks on the banner, the website of the sponsor of the
advertisement is displayed. Banner advertisement is most common and is used
by Yahoo.com, Rediff.com etc. to generate revenue for their business.
2. Subscription Revenue Model
In this model the Company charges the users a subscription fee for having
access to the material, offering it has on its website. Those who subscribe to this
website are given a username and password using which they can access the
website. Generally the subscription fee is valid for a certain period of time only.
The content of the websites that use this model
a) should not be available elsewhere for free.
b) must be a premium offering and should be perceived to be of high value.
A Company's website which offers daily tips to traders on the share market is
one example of such a model. Another example is Consumerreports.org which
charges a monthly subscription fee of $5.95 and a yearly fee of $26 to its
subscribers.
3. Transaction Fee Revenue Model
In the Transaction Fee Revenue Model, a company charges a fee for the
transaction it carries out. The fee amount depends on the number and size of the
transactions. An example of such a model is websites that allow online auction
facilities. Most of these websites charge a small fee when the item is sold. An
example of this is ebay.com.
4. Sales Revenue Model
In the Sales Revenue Model companies obtain revenue by selling various
products, information or services to its customers. Websites that market
products and build sales revenue from merchandising belong to this model. For
this the website has to build a brand of its own. An example of this is
Amazor..com which is one of the popular sites for purchasing books.
5. Affiliate Revenue Model
In the Affrliate Revenue Model companies send business to an affiliate and
receive a suitable fee which could be a flat fee, or even a percentage of the
revenue generated. They also earn revenue by offering incentives for the
transaction that take place. This is done by offering potential customers special
deals. When the customers take advantage of this and make any purchase, they
earn point which can be redeemed against various gift items. The company
benefits from the fee it receives for sending the business to the affiliate. An
example of this is mypoints.com
MA"TOR BUSINESS - TO - CONSUMER (B2Cl MODELS
The major B2C E-Commerce models used to generate revenue by doing
online transactions with consumers are listed below :
1. PORTAL
A Portal offers its users an integrated package of content and services, which
include news, events, e-mail, sports, shopping, video streaming etc. along with a
powerful search engine for searching the net. It becomes a starting point for most
users. Users are attracted to visit these portals and spend time looking up things
which interest them.
Many businesses place their advertisements on such portals, as they get a
ready audience for marketing the product/ service. They pay the Portals a fee for
Tgpes of E-Commerce and Business Models jl ;t'tt, 11
keeping the advertisement for a given period of time. The amount also depends
on the position where the advertisement is placed, with more prominent positions
being charged a higher fee. The revenue earned by Portals is mainly from
advertisements and referrals to other sites. The Portals themselves do not sell
anything.
2. E.TAILER
E-TAILER delivers the product direcfly to the consumer on receiving the
order. E-Tailer is not the manufacturer of the product and is nothing but an
online version of a retailer.
E-Tailer is of two types :
af Rrre plays : Their only means of retailing is the internet. They do not
have any physical store made of bricks and concrete. They can earn
higher profit margins as there are no high over\ead costs to take care of.
An example of this is amazon.com.
b) Brtcks and clicks : They have a physical store where they sell directly to
consumers who'walk in, and they also do retaitng on the internet. They
enjoy the benefit of both types of businesses. They can do better business
and earn higher returns.
3. CONTENT PROVIDER
Content Providers distribute various forms of information, such as news
items, artwork, videos, photographs, text etc.(Intellectual Property) on the web.
Content Providers charge a subscription fee for making these facilities available
to the user. These sites earn their revenue by charging a subscription fee which
can be monthly or yearly. Further specific downloads made are charged
depending on their content and size.
Major newspapers are available on the internet free for reading
e.g. timesofindia.com, expressindia.com, mid-day.conl etc. They allow you to read
most of the headlines, however for reading the full contents of the paper most of
them charge a subscription fee.
4. TRANSACTION BROKER
Transaction brokers charge a commission for facilitating transactions. They
bring the buyers and sellers together, so that a trade takes place. These
transactions could be financial, travel related, placements etc. The brokerage firm
eTrade has grown by going online, and it has lowered the commission charged to
the customer's. Transaction brokers earn more if they attract new customers or
the existing customer's trade more often. They provide opinions on various
financial matters and provide timely information. Job placement sites such as
naukri.com provide job openings all over India, hence are providing a national
marketplace.
5. MARKTT CRTATOR
Market Creator model uses internet technolory to build markets where
buyers and sellers can meet, decide on a product and fix the price for that
product. The web has made it possible to delink markets from physical space.
EBay.com is one such digital market place. There are no intermediaries, the
buyers and sellers have to decide on the transaction themselves as there are no
agents to represent them. EBay.com earns revenue by charging a fee to list the
product and also a fee on each sale. This may sound very lucrative, but the
digitaf market place has to attract many buyers and sellers otherwise the model
will not be feasible.
12 tt"tl't' Computer Systems andApplications-T.Y.B.Com.-(Sem. VI)
6. SERVICE PROVIDER
Service providers provide services ontne. The services that are provided by
them range from email, sharing videos and photos, and sharing various other
materials created by the user. These service providers trade their knowledge and
expertise for revenue. Hence even sites which promote social networking are also
covered under this model. Most Service providers earn their revenue by charging
for advertising space that they provide.
Google maps, orkut, and Gmail are examples of service providers.
1. COMMUNITY PROVIDER
Community providers are sites which create a digital online environment,
which enable people with similar interests to transact and communicate with like
minded people. They may also share photos and videos. They rely on hybrid
revenue models and earrt their revenue from subscription fees and advertising.
oBJECTTVE QUESTTONS
I. State which of the following is tnre or false :
1. B2B E-Commerce is between Business to Business and consumers.
2. ANSI ASC X12 is a popular standard used in B2B E-Commerce.
3. Brokers facilitate transactions in B2C between buyers and sellers.
4. E-tailers are not direct sellers.
5. In C2C E-Commerce consumers transact with other consumers through a physical
market.
6. In the subscription model a fee is charged to the user for having access to material
on the website.
7. Orkut is a type of service provider.
8. B2C E-Commerce is seller driven.
9. In e-auctions one of the greatest advantages is that there is physical inspection of
goods.
10. The volume of B2B transactions being done is more than B2C transactions.
11. Transaction brokers charge a fee for facilitating transactions.
12. There is no scope for negotiations in B2B E-Commerce.
13. There is no scope for negotiations in B2C E-Commerce.
14. More securitSz is required in B2C E-Commerce.
15. ebay.com is an example of Transaction Fee Revenue model.
L6. B2C refers to Business selling goods to other business.
17. E-tailer is a online retail shop.
18. In E-commerce Ubiquity refers to Universal Standards
L9. B2B refers to a Business selling goods to other individuals.
20. Portals are focused around a particular market segment.
21. Transaction Brokers make money each time a transaction occurs
22. ebay.com is an example of C2C E-Commerce.
23. Digital signature changes for every document.
U. Select the approprlate optlon from the followlag :
1. The fulI form of P2P in E-Commerce is :
a) Peer to Peer b) person to person
c) Peer to Person d) person to peer
2. The full form of B2B in E-Commerce is :
a) Bill to Bill b) Business to Business
c) Bill to Business d) Business to Bill
Tgpes of E-Commerce and Business Models n'n"n' 13
lANswERsl
9. [True : 2, 3, 4,6, 8, lO, 11, 12, 13, 15, 17, 2l
False : 1, 5, 7,g, 14,16, 18, lg, 20,22, 23.1
10. [(1 -a)(2-b) (3-c) [(4-c) (s-b) (6-blV -a) (8-c) (e-c) (10-a) [(11-c) (12-d)]
QUESTIONS
1. State the various types of E-Commerce.
2. Explain B2C E-Commerce.
3. Explain C2C E-Commerce.
4. Explain what are the classifications of B2C E-Commerce.
5. Explain in brief the various business models in E-Commerce.
6. Gives the names of 5 B2C business models and explain any one.
7. Explain what an E-tailer is.
8. What are the different types of Revenue models in E-Commerce?
t'r"t'
\
14 t'll'l," Computer Sgstems and Applications - T.Y.B.Com.-(Sem. VI)
3 E-Commerce Security
One of the things that have slowed down the growth of E-Commerce is the
problems of security. Many of those who would like to use E-Commerce are afraid
about the theft of their credit card numbers. This is because the technologies
that form the basis of E-Commerce can be used to obtain confidential
information. Some of the issues of security in E-Commerce are discussed below :
1. INTEGRITY
Integrity refers to the ability to check and ensure that the data being
displayed on a web site or what data is sent over the internet has not been
changed in any way. This can be done if it is possible to authenticate and veri$r
who sent the information and from which computer and tJlat the information has
not been tampered \rith.
All those who want to use E-Commerce will be harboring suspicions on the
integrity of the system. Only those with the authority to access and alter the data
should be capable of doing so. If this power falls in the wrong hands, the threat to
the integrity of the system is very real and can be very dangerous. A digital
signature is normally used to ensure integrity of the message and this is
discussed later in this chapter.
2. ITON REPUDIATION
Non repudiation refers to the requirement that the parties who are doing
E-Commerce, narnely the buyer and the seller, do not deny that they have
initiated the transaction.
This means that the buyer should not deny placing the order and the seller
should not deny that the order has been received. The main worry for the
company doing E-Commerce is that the customer should not deny placing the
order, as this will mean the company loses money on freight and packing. For the
customer, the worry is of someone hacking into their account and placing an
order on their behalf, and using their credit card number. Thus non repudiation
is used to ensure that the buyer and the seller cannot deny that the transaction
has occurred.
3. AUTHENTICITY
Authenticity refers to the ability to determine the origin of the message
received over the internet. This refers to knowing the identity of the person who
has sent the message, from where the message was sent and the identity of the
computer used to send the message.
Proper identification is very important for both the parties dealing in
E-Commerce. It would help confirm whether the order received is genuine or not
and would eliminate the possibility of fraud.
4. CONFIDEI|TIALITY
Confidentialit5r ensures that the message and data are viewed only by the
person to whom they are sent and who has the authority to view them. These
concerns regarding access to data and privacy are meant to ensure that within
E-Comm.erce Securitg fI'll' 15
an orgatization no unauthorized person can lay their hands on such information.
It is well known that there is very sensitive data, such as credit card details,
which are sent as part of an E-Commerce transaction. It is important to ensure
that evrcn if the data is hacked into, it cannot be easily read. Normally to ensure
confidentiality data encq4ption is used, which is discussed later.
5. AVAILABILITY
Availability means that the E-Commerce systems are available continuously
at all times when needed. The customer must get a fully functional E-Commerce
site which works as it is intended to. It would be very irritating to the customer to
see that the site is down due to some problem, when a transaction has to be
urgently done.
As long as all the above mentioned dimensions are functioning as intended
there will be no securit5r issue in E-Commerce.
ENCRYPTION
Encq4ption is the method of protecting internet messages from being read by
anyone, while they are being sent between sender and receiver.
Encryption transforms messages and data to protect their meaning. The
message is so scrambled that it can be understood only by the person who knows
the method of encryption and holds the key to decipher the message. Hence
Encryption is the conversion of readable text into characters (cipher text) that
disguise the original meaning of the text.
Encryption using
Readable text Cipher text
encryption key
There are two primar5r forms of encryption systems, Private Key Encryption
and Public
Key Encryption.
PRI1IATE KEY ENCRYPTION
In Private Key encryption thesame key is used to encr5pt and decrypt a
message. A key is an Algorithm which is used to encode and decode a message.
Encryption can be done by substitutlon or transposltion. In substitution
method every alphabet is replaced by another alphabet. This becomes quite
predictable as a given input will always give after encryption the same resultant
output. In transposition the letters are re-arranged and are controlled by a key.
Hence this is a better method as compared with the substitution method.
Though Private Key encr5rption sounds very simple it has many problems. For
example, how do you distribute the key securely? One way is to send the key with
the message, however if the message is intercepted, then the key is also obtained
and it will be used to decipher the message. Other ways could be to send it by fax
16 ,"r"t" Computer Systems andApplicatians-T.Y.B.Com.-(Sem. VI)
or give it over the telephone. None of these methods is really secure. Also what is
the guarantee that the receiver of the key will protect its secrecy? The other
problem is that a separate private key will h"r" to be created for each
organization with which encrJapted messages are exchanged.
PUBLIC KEY ENCRYPTION
In Public Key Encryption there are two keys, one private and the other
public. The public key is freely given and is used to encr54pt the message received
by you. On the other hand the private key remains secret and is used to decrypt
message which have been encqpted with the private key by the sender.
Hence the public key is freely given to everyone who is going to send
messages. The message will be encr5pted with the public key by the sender. On
receiving the message the private key will be used to decrypt the messagc Hence
the private key, whick is the 6nly kev which can decrypt the message, remains
secure with the receiver.
Rrblic Key Encryption
The method used in Digital Signature with Public Key System is as follows :
a) The sender encr5pts the message to be sent using the receiver's Public
key.
b) The sender then adds a Digital Signature to the message using his Private
Key, so that the sender's identity can be verified. .
c) The receiver of the message then verifies the identity of tJ:e sender of the
message using the sender's Public key.
d) The receiver of the message then uses his Private Key to decrypt the
message.
Digital Signatures have been made legally binding in some countries.
sEcuRE socKET LAYER{SSLI
Security of data in transit over the internet has become increasingly
necessary. Secure Socket Layer is a protocol developed by Netscape for securit5r of
data in transit, which covers all networks that use TCP/IP to support
communication between servers and clients. Both Netscape Navigator and
Internet Explorer support SSL and many of the websites use this protocol to
obtain credit card numbers over the internet. There is a convention that all sites
that use a SSL connection use HTTPS instead of HTTP.
SSL uses a program layer located between the Internet's H5rpertext Transfer
Protocol (HTTP) and Transport Control Protocol (TCP) layers. The SSL protocol is
used to give data encryption and authentication of the server. Browsers that use
SSL protocol show a dialog box on the screen to indicate that a secure session is
ongoing, while Netscape shows a blue key to indicate the same. SSL uses a
cryptographic system where two keys are used to encqpt the data, namely the
public key and the private key and also includes the use of the digital certificate.
SSL has recently been succeeded by Transport Layer Security (TLS) which is
based on SSL.
PAYMENT SYSTEMS
When comrnerce has become Electronic, the means of paying for goods and
services has also become electronic. The traditional paper based systems used for
making payments cannot give the speed, privacy and internationalization needed
in E-Commerce. The following payment systems are used in E-Commerce :
1. DIGITAL CASH
Digital Cash is the electronic parallel of notes and coins. It is a string of
numbers that represent an amount of money. The customer or consumer has to
deposit cash in the bank, in lieu of which, the bank will be give electronic
authenticated (digital) tokens. The customer can then use this to pay for what is
purchased electronically. The merchant who receives these electronic tokens then
deposits them in his bank and his bank credits his account.
18 t't "'" Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
+-> <-|>
Internet
Customer Merchant
00
llFIl
!r rr
ht
Merchants Bank
Customers Credit
Card Issuing Bank
5. The clearing house sends the information over the appropriate credit card
network to the customers issuing bank for verification and payment. The
customers issuing bank generates a confirmation number which is sent to
the merchant via the clearing house.
6. The merchant sends this confirmation number along with purchase order
details to the customer and requests the customer to take a print out of
this information for the customer's record. The merchant then proceeds to
shipping the order.
7. At the end of the day the customer's issuing bank sends the amount of
the transabtion to the clearing house. The clearing house credits the
merchant's bank with the amount and keeps a small percentage as
processing fee. The customer's issuing bank sends a monthly statement
to the customer for pa5rment which contains the details of purchases
made during that nionth.
LIMITATIONS OF ONLINE CREDIT CARD PAYMENT SYSTEMS
1. Processing fees r The merchant has to pay the clearing house, a certain
transaction fee for processing the order.
2. Security : As the buyer and seller never get to meet or see each other in
this form of commerce, neither of them are fully authenticated. The
merchant cannot tell if the credit card is in the hand of one's spouse, a
thief or a 13 year old child.
3. Availabillty : There are many consumers who do not possess a credit
card, hence this entire segment of the market is not available for E-
Commerce using credit cards.
sEcuRE ELECTRONTC TRANSACTTONS(SETI
A secure electronic transaction (SET) is a protocol jointly developed by a
consortium consisting of Visa and MasterCard and is jointly administered by
them. It is one of the standards for handling transactions on the internet. It
ensures secure and reliable transaction processing in E-Commerce. The main
features of SET protocol are as follows :
a In a SET protocol all the sensltive information sent between the customer,
the merchant and the merchant's bank is encrypted.
o All the above three parties have to get themselves authenticated by the
SET certificate authority.
o The customer's credit card number is never seen by the merchant.
SET covers all the aspects of online commerce. It authenticates the
identification of the parties involved in the transaction by using a combination of
cr54ptography systems along with digitaf certificates. SET was developed to
ensure.
a) Confidentiality of payment.
b) Integrity of transmitted data.
c) Authentication of the cardholder as well as the merchant's ability to
receive payment by a credit card, and
d) Interoperability across network providers.
The protocol defined by SET is quite complex and hence
it is not economical
for small payments. To implement SET its software such as SET "electronic
wallet" must be installed in the client's Web Browser. It is a big chatlenge to make
such software widely available.
E-Commerce Seanritg t"t?' 21
OBJECTIVE
I. State whether the following statenents are Trre or False :
1. Electronic Market is the virtual representation of physical market.
2. E-Commerce means buying and selling of products by consumers and businesses at
the local level.
3. In E-Commerce scope is local.
4. EDI stands for electronic data interchange.
5. EDI does not require printed order and invoice.
6. AII products and services can be sold through E-Commerce.
7. E-Commerce stands for Electrical commerce.
8. The cost of the products sold through E-Commerce is very high.
g. E-Commerce is the most secure and private system.
1O. Payment is done by credit card in E-Commerce.
22 t"t'tt' Computer Systems and Applications - T.Y.B.Com--(Sem. VI)
23. There are many techniques used by B2C companies to attract customers except
a) Viral Marketing
b) Online Ads
c) Registering with search engines
d) Discount Price
24. T}re most commonly used form of paJrment in E-Commerce is
a) Credit Card b) PayPal
c) Petro Card d) Digital Cash
ANSWERS
13. [Tnre. 1,4,5, lO, 13,t4,15, 16,77,18, 19,22,23,24,25,27,28
Falso '. 2, 3, 6,7,8,9, lL, L2,20,21,26.1
14. [(1 -bl,e -b),.(3-c), (4-a), (5-c), (6 -dl,V -b), (8-d), (9-a), (10-d), (11-"),
(12-c),(13-b),(14-c),(15-b),(16-b),(17-c),(18-a),(19-a),(20-d),(21-al,
(22 - cl,123 - al, Qa - a\
OUESTIONS
1. Discuss the various securit5r issues in E-Commerce.
2. Explain the terms: Encryption and Decryption.
3. Discuss Private Key encr5ption.
4. Discuss Public Key encr5ption.
5. What are digitaf signatures? What are they used for?
6. Explain SSL.
7. Discuss the pa5rment systems used in E-Commerce.
8. Explain the working of an online credit card transaction.
9. What are the limitations of credit card payment systems?
1O. Explain the SET protocol.
I1. What is M-Commerce? What are its applications?
t ?'t"
Microsofi, Excel - Multiple Spreadsheets t'lr?' 25
ODULE II
DVANCED MS-EXCE
4 - Multiple
Microsoft Excel
Spreadslteets
TEMPLATES IN EXCEL
Microsoft Excel 2OO7 contains many features that allow the user to automate
certain tasks such as entering formulae, formatting a worksheet, etc. To avoid
repeatedly creating a worksheet from beginning, we could create a template and
reuse it with minor modifications.
A template is a predesigned utorksheet that you can use to create new
worksheets with l}:e same formatting and predefined formulae. Tlre template
worksheet contains all the formatting such as'font and layout information,
conditional formatting, labels, data, titles, and values.
CREATING A TEMPLATE IN EXCEL
1. Open new worksheet.
2. Enter all the data such as column headings, formulae, font information.
Align each column the way it is required.
3. Add or remove rows and columns as required.
4. Create charts.
5. Now save the template as follows:
a) Click on the Office button to open the drop menu.
b) Choose the Save As option.
c) Choose the Other Formats option.
d) Choose the Save As option to open the Save As dialog box.
e) Click on the Save as type option to open the drop down list.
0 Scroll through the list to find the template options.
g) Select the option Excel Template (*.xltx) and click on the Save button.
6. The template is saved in the templates folder on your computer.
LINKING MULTIPLE WORKSHEETS AND WORKBOOKS
. Excel can dynamically link a workbook to data in another workbook so that
any changes you make in one workbook are immediately reflected in the other
workbook. This other workbook may be situated on your own computer or it may
be situated on another computer which are connected through a network. We will
now explore this feature of Excel - linking worksheets and workbooks.
26 t't'l,' Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
LINKING WORKBOOKS
The term linking refers to the process of creating formulas that use values
contained in another workbook. That is, worksheets are linked in such a way
that one depends on the other. The following terms apply to linking documents :
External Reference : This is a reference to another Excel workbook cell, cell
range, or defined name. A formula containing an external reference is called an
external reference formula.
Dependent Workbook : It is a workbook that contains a link to another
workbook. In other words, a workbook that relies on (or, depends on) information
in another workbook is called a dependent workbook.
Source Workbook : A workbook that is the source of the information referred
to in an external reference formula; source workbooks are referred to by
dependent workbooks.
Itrhy Ltnk Workbooks?
If a workbook A relies on the data in another workbook B, then linking of
workbooks becomes necessary. One may just as well copy the data from
workbook B into A, but this process can be very cumbersome. If workbook B is
being continuously updated from some source (say, the share prices of 5O0
companies in a stock broker's office), then it is impossible to update workbook A
manually. The only alternative is to use the method of linking.
Linking is also required sometimes if one of the workbooks itself would
contain too much data. In such a case, it is advisable to break up a large file into
two or more smaller files and link them with each other.
Linking has its drawbacks, however. If link in one of the formulas in linked
workbooks is broken, then the workbooks will be "out of s5rnc".
CREATING LINKS
The general syntax for an external reference formula is :
= [WorkbookName]SheetNamelCellAddress
The cell address is preceded by the workbook name (in square brackets), the
worksheet nalne, and an exclamatio4 point. E.g., tJle following fgrmula uses a
cell reference in the sheet named MarchExpd in a workbook named Budget 2008.
='[Budget2o08]MarchExpd'lProvisions.
The other workbook need not be open. If the above workbook was closed,
then we can use the formula
= D: \My Documents\ [Budget2oo8]MarchExpd'tProvisions
Here we have given the complete path to the reference.
Creating a link formula by polntlag
Reference formulas can be entered directly, but doing so may result in typing
errors (typos). Instead, one can let Excel build the formula for you.
1. Open the sourcebook.
2. Activate the cell in the dependent workbook that will hold the formula.
3. Begin entering the formula.
4. When you get to the part that requires an external reference, activate the
source workbook and select t\e cell or range.
'5. Finishthe formula and'pre"* BtttpR
Microsofihcel-Mukiple Spreadsheets d11'f 27
If tJ:e source workbook is open, the external reference will not include the
path to the workbook. But if you close the source workbook, the external
reference formulas will change so as to display the complete path.
Creatlng a llah fornula by parttag
The Paste Special command can also be used to create external reference
formulas :
OK Concel
.
.ng. 4.1 : Sclcc+tig Perte Spccial
Eramplc : Let us consider an example of linked workbooks. First create a
workbook called UOIITHLYIIIC.XI,8X. This will be our source uorkbook Tirre
worksheet on this workbook is named MONTHINC and has the following contents
(Fig a.2).
UOIITIILYIilC.XLSX (Source workbook)
A B c D E G
I MONTH BASIC DA CI"A HRA GROSS DEDNS
2 Mar-O8 9300 344L 300 2790 15831 L260
3 Apr-O8 9300 3441 300 2790 1583r 1260
+ May-O8 9300 3441 300 2790 15831 1260
5 Totd 27900 10323 900 8370 47493 3780
6
? Other Income 1 1000
ry.4.2 t Sourcc Worlbool
The formulas in various.cells are :
CellF2:=SUM(B2:E;21.
Copy this formula in cells F3 and F4.
CellB5:=SUM(B2:841.
a
.) J
28 jPt/f Comgruter Sgsrems andApplimtions-T.y.B.Com.-(Sem. VI)
Copy this formula in cells C5, D5, 85, F5, and G5. Note how the formula
adjusts to take on relative references.
Now create a workbook named TAXCALC.XI,SX. This will be the dependent
uorkbook. Contents of tJlis workbook are shown in Fig 4.3 below.
TAXCALC.XLSX (Dependent workbook)
A B
I Tar Conputatioa
2 IGro"" Income
l
3 lDeductions
4 lN.t I.rcome
5 lOtn.r Income
6 lfaxable Income
? ltax Payable
Flg. 4.3 : Depcndcnt WorLbooL
As you can see, the contents of column B are empty. We will fill up the cells
in this column by linking cells from workbook MONTHLY-INC.XLSX.
Here are the steps to link these two workbooks.
1. Open the dependent workbook TAXCALC.XLSX.
2. Open the source workbook MONTHLYINC.XLSX.
3. Click on cell F5 (of MONTHLY-INC.XLSX) and copy the contents of this cell
to the Clipboard (Press CTRL + C).
4. Switch to TAXCALC.XI,SX workbook (ALT+TAB will work for switching).
5. In the worksheet TAXCALC.XLS, click on cell 82. Right click and select
Paste Special. Click on Paste Link button. You will find the value 47493
appears in cell 82. Also, obsenre the formula bar; the following formula
appears :
= [MONTHLYINC.xIsx]MONTHINCT$F$5
The first part of the formula (in square brackets) contains, the workbook
narne, followed by the worksheet narne, and the cell we copied from that
worksheet, cell $F$5. Note the absolute references in linking.
6. Activate MONTHLYIilC.XLSX and copy cell GS to Clipboard (press
CTRL + C). Activate TAXCAIf.XLSX. Select cell E}3.
7. Right click and select Paste Special and click on Paste Link button. You
will find the value 3780 appears in cell E}3. Also, observe the formula bar;
the following formula appears :
= IMONTHLYINC.xIsx]MONTHINCT$G$5
8. In cell 84 type the formula, =B.2-rr. '
9. In cellB5, type the formula, =[MONTHLYINC.xIsx]MONTHINC!$B$Z
10. In cell86, type the formula, =84+85.
1 1. In cell 87, type the formula, =15"86/ 1O0 (Tax rate 15%).
Note that we have tsed formulae, and relative referencing and these concepts
you have studied in Semester 5.
Microsofi Etrcel - Multiple Spreadsleets ,.il r' 29
The completed worksheet should look as shown below :
TAXCALC.XLSX (Dependent workbook) after linking with MONTHLY-INC.
xLsx
lr B
1 Tar Computatlon
2 lc.o"" Income 47493
Deductions 3780
Net Income 43713
Other Income 1 1000
Taxable Income 547L3
Tax Payable 8206.95
UPDATING LINKS
Whenever there is a chonge in the source utorkbook, t};.e dependent uorkbook
is automaticallg updoted. In the above example, change the contents of cell B7 in
MONTHLYINC.XLSX and observe how the contents of TAXCALC.XLSX are
automatically updated.
If the source workbook is closed, the cells in dependent workbook will not
update automatically.
USING FORMULAE AND LOGICAL OPERATORS
A spreadsheet is a number cruncher. It can perform various mathematical
calculations on numbers and for that it needs formulae. We have seen, in
Semester 5, how to create and use formulae. A few basic concepts of formulae
are :
o Excel formulae must start with the equal to symbol ( = ); this is how
A11
Excel distinguishes between a formula and text.
o Formulae may contain the following mathematical symbols : *, *, -, /, n
(exponentiation), 7o (percentage), brackets (and ).
a A formula can contain cell references, values, and worksheet functions.
a When you enter a formula in a cell, the cell displays the result of the
formula. The formula itself appears in the formula bar when the cell is
activated.
Logical formulae : These contain the relational operators (r ), =, )=, (=, ().
These operators operate on two conditions to produce a logical result. i.e., TRUE
or FALSE.
LOGICAL FUNCTIONS
Excel uses the following logical functions - AND, OR, NOT, TRUE, FALSE, IF
and IFERRORfl. All these logical functions return TRUE or FALSE as the result.
$I$tr , AND(logicatl,logical2,...) tests whether ttre logical arguments are TRUE
or FALSE. If ALL logical arguments are TRUE, the AND function returns TRUE. If
any argument is FALSE, the AND function returns FALSE. Thus, all arguments of
the AND function should be TRUE to get a TRUE output. Think of this as follows:
You are allowed to board an international flight if you have the ticket AND the
passport.
I \
30 l"9'n' Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
.t
CottrmcDt
A FumrH*nhCdI cffir ofFmdr
=TRUE TRUE
ryqf no
I
It{AItr{,'losilp is','tleFtyEl $mnumber inA2Tispositin,ilnfiI5tpadof $earyrentisprinted
J it{AH,'PoiitiE rd,'tle$lire'} ttqltir? Sinoenur6s k AB b n€Ftiredpxod nrytof tpsEltxrdis$ilted
It ) rr0i0(4D0, h901, "Bdt Positin" 'sdr arc nd puitiw') mrPositin Sinebdnmieraepoilire,Al{Dretuns1lUtadfirstaryumntb$wn
17 (
+lAl{D{l3S, 83001,'8dl hsitive','Bdl ae ndportive'l BdlmnotpGitiye $neBIb nqative,tcA+tl}returE FA$Eand $fieseondaBJmert brdntd
Write a nested IF statement that will display the appropriate grade. Assume
mark is in cell A1 and grade must be displayed in cell81.
Ans. : Cell81 will have the formula:
=IF(A1 >=90,"A", IF(AI >=80,'B', IF(AI >=7O, "C", IF(A1 >=60, "D", "F'))))
IFERROR : IFERROR(ualue, errualue) tests whether the ualue expression is
an error. IFERROR returns emtalue if the expression is an error, or ualue of the
expression if it is not an error.
B c D
1 Quota UnitsSoH Forrrrula inColumn D Valu€ returned by Formula
2 2W =lFERRoR{A2/Ba "Error in calculation" ) 6
3 55 0 =IFERR0R{A3/83, "Error in ealculation"} Errar in calculation
4
!
i
<-click here
Tax
210000
O&IECTTVE QUESTIOIYS
I. State whethcr thc follorlag are ttrc or felrc :
1. A formula may start with any symbol.
2. Worksheets can be linked with each other only if they are in the same workbook.
3. When a worksheet in one workbook is linked wit],. another worksheet in the same
workbook, then the workbook name does not appear in the linked formula.
4. A template has the file name extension .XLTX
5. Named ranges use absolute referenqes.
6. Worksheets created with a template can have same formatting but cannot use
predefined formulae.
7. A template is saved in the templates folder.
8. An external reference is a reference to a cell in another Excel workbook.
9. A dependent workbook contains a link to another workbook.
10. There are no drawbacks to linking workbooks.
11. The general syntax for an external reference formula is :
= [WorkbookName]SheetNameiCellAddress
12. The Paste Special command can be used to create external reference formulas.
13. If
there is a change in the source workbook, the dependent workbook is not
automatically updated.
14. Logical formula can contain only the *, -, * alad I operators.
15. A logical formula can have only two possible outputs: TRUE or FALSE.
16. The logical function AND returns the value TRUE only if all the conditions in it are
TRUE.
17. The logical function OR returns the value FALSE if any one condition is FALSE.
18. The logical function NOT returns the value FALSE if its argument is FALSE.
19. The advantage of creating named range is that it makes the formula more readable.
20. Once a named range is created, it can be edited or deleted.
Microsofi, Excel - Multiple Spreadsheets lr,t,3;, 35
U. Multiple Choice Questions
Select the most appropriate alternatlve from amoagst those glven and rewrite
the sentence :
1. When you are typing a formula in a cell. The first thing that must be entered is :
a) the first cell referenced. b) parenthesis.
c) quotation marks. d) an Equal sign.
2. Which of these is the correct way of referencing a cell A1 on worksheet named
Admissions2OO9 in the same workbook :
a) =Admissions2OO9lAl b)
=Admissions2oog-A1
c) =A1lAdmissions2oo9 d)
=Admissions2oog
3. When referring to a cell in another worksheet (same workbook), the sheet reference is
always _, while the cell reference may be _.
a) absolute, relative b) relative, absolute
c) mixed, absolute d) relative, mixed
4. The result of a logical formula is
a) a logical value True or false b) a text va-lue
c) a numeric value d) an error message
5. Excel templates have the file narne extension
a) .temp b) .xltx
c) .xtemp d) .xls
6. A template worksheet contains the following information:
a) font and layout information b) conditional formatting
c) labels d) all of these
7. Consider the formula =[MONTHLYINC.xIsx]MONTHINC!$F$5. In this formula,
a) MONTHLYINC.xIsx is the external reference
b) [MONTHLYINC.xIsx] is the external reference
c) [MONTHLYINC.xIsx]MONTHINC is the external reference
d) [MONTHLYINC.xlsx]MONTHINC!$F$5 is the external reference
8. If cell A3 contains 10 and cell A4 contains 15, then what is the return value of the
formula = AND(A3 > 9, A4 < 2O)?
a) TRUE b) FALSE
c) 2s d) -s
9. If cell A3 contains 10 and cell A4 contains 15, then what is the return value of the
formula = OR (A3 > 9, A4 < 5)?
a) TRUE b) FALSE
c) 2s d) -5
10. If cell A3 is named PassMks and contains the value 40, cell A4 contains the number
76,what is the value of the expression =IF (A4 >= PassMks, 'Pass", "FaiI")?
a) Pass b)
Fail
c) Error d)
None ofthese
1 1. A selection consisting of two or more cells on a worksheet is called
a) Area b) Unit
c) Range d) Name
12. Which of the following is a valid external reference formula?
a) =<2008 Forecast>Fourth Quartert$D$8
b) ={2008 Forecast}Fourth Quartert$D$8
c) =[2008 Forecast]Fourth Quarterl$D$8
d) =[2008 Forecast]tFourth Quarterl$D$8
ANSWERS
I. [True : 3, 4, 5,7, 8,9, lI, 12, 15, 16, 19, 20
False z 1,2,6, 10, 13, L4,17, 181
III. [(1 -d), (2-al, (3-a), {4-al, (5-b), (6-d), (7-d), (8-a), (9-a), (10-a), (11 - c),
(12 - c)l
4/T.Y.B.Com - Com. Sys. & Appl. (Sem. -VI)
36 t't'l,' Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
QUESTIONS
I. State the steps to perform the folloslng operatloas i! Uicrosoft EacGl :
l. Add the contents of cell Al of Sheet2 and contents of cell E}1 of Sheet3 and store the
result in cell ,{1 of Sheetl. (Assume active worksheet is Sheetl).
2. Multiply the contents of cell A1 of Sheetl in workbook "C:\My Documents\
Expd2gOO" by 1O, and store the result in cell A1 of Sheetl of the currently open
workbook.
3. Create a template in Excel.
4. How can an external link be created by pointing.
5. How can a narired range be created for the range of cells C5:C20?
6. How can a named range be deleted for the cells C5:C2O?
7. Cell Al contains the speed of a vehicle. Write a formula in cell B1 that dtsplays "Safe"
if speed is less than or equal to 5O, otherwise it displays "Slow Down"
II. Wrlte shott answerg :
1. What is a template? State the advantage of templates.
2. Explain the advantages of linking worksheets.
3. Explain the general syntax for an external reference formula.
4. Explain how a link formula is created by pointing.
5. Explain how a link formula is created the Paste Special command.
6. What are logical operators in Excel? Explain any three of these.
7. Explain the IFERROR$ function with a suitable example.
8. Define the term tramed range'.
9. State advantages of a named range.
10. Which type of referencing does a named range use? Why?
PRACTICAL EXERCISES
l. The following data is entered in a worksheet :
A B c
1 Name Basic TA
2 Nikhil 22000
3 Reema 27000
4 Namrata 27500
D Bhavika 20500
6 Rajesh 25000
Cell C2 contains the formula
= IF(82 < 23OOO, 1500, IF(B2 < 25OOO, 1800, 2000)).
This formula is copied down into the range C3:C6. What are the values shown in
cells C2:C6?
2. Consider the following spreadsheet which shows the marks obtained by 6 students
in an exarn. Write steps to obtain the average where average is the average of the
best five subjects for each student. The result is "Pass" if average is 5O or more and
"Fail" otherwise.
A B c D E F G H I
1 NAME ENG HINDI ECO BK AIC Tax AVERAGE RESULT
2 HEENA 78 69 77 65 88 73
3 SHWETA 87 79 75 77 91 81
4 FALGUNI 81 68 80 60 87 81
5 AKSHATA 64 59 58 61 69 63
6 ASHWINI 72 63 65 61 70 7t
Microsofi Excel - Multiple Spreadsh.eets t't"t' 37
3. In a worksheet, Names are entered in column A and corresponding Basic Pay is
entered in column B for 3O persons the first row contains the heading and the rest of
the rows contain data. Write the steps to obtain in column C, D and E the HRA, DA
and Total Pay where HRA is @ 2Oo/o of basic pay or Rs 5OO0 whichever is less, and
DA is 25o/o of basic pay whenever basic pay is less than 5OOO otherwise it is 4O% of
basic pay.
4. A University decides to scale down the marks of a student in Internal exams as
compared to the marks obtained by the student in the Semester End Theory exam in
the subject concerned. The rule is as follows: If the percentage of marks obtained by
the student in Internal exam and Semester exam differ by more tl:an 2Oo/o than the
percentage of marks in the Internal exam should be scaled down to 2Oo/o. If the
difference in percentage is less than 2O%o, the Internal marks are not changed. If the
Semester percentage is more than Internal percentage, the Internal marks are not
changed. Assume that the student is passing in the course. Write the formula in
various cells that will generate the data shown in ranges,C3:C5, E3:G5. Data in other
cells is to be assumed.
A B I
C D EF G
1 Semester Mlts Semester%pcE lnt Mh-Org lntwnalkQ Diff in Pclg Ret is€d lnternal
2 Max Mks--> 50 N
3 Atrts 30 50 38 95 its 8
4 Eco 49 82 t7 93
I
11 37
I
Maths 58 9? 37 93 -4 37
6
t'''t"
38 t't"t" Computer Sys/ems and Applications - T.Y.B.Com.-(Sem. VI)
5 Microsoft Excel
Functions
F'UNCTIONS IN EXCEL
We have already studied a few functions in Excel in Semester 5. These were
the financial, mathematical and statistical functions. In this chapter we study a
few more functions that are extremely useful for commercial applications. At the
end of this chapter, you will be able to :
o Use string-handling functions.
o Use functions for working with dates.
a Apply conditional logic functions in spreadsheets.
a Use database functions to lookup data.
FUNCTIONS REVISITED
In this section, we briefly revise the basic concepts of a function. You can
refer to the textbook of Semester 5 for details of Excel functions.
Frrnctlon t A function is a special prewritten formula that takes a value or
values, performs an operation, and returns a value or values.
Function Arguments : The values that we supply to the function, within
parentheses, are called the function arguments. Functions may have :
a No arguments
a One argument
a A fixed number of arguments
o Any number of arguments
a Optional arguments
Return Values : The values that a function produces after computation, are
called the return ualues. The values returned by a function can be used by other
fu nctions for further calculations.
Syntax : The sequence of characters used to enter a valid function is called
the sgntax. All functions have the same basic s5rntax. The function name is
followed by the arguments in parentheses. If a function uses more than one
'argument, each argument is separated by a comma.
ENTERING FUNCTIONS
Excel's built-in functions can be entered either manually or by using Excel's
Function Wizard.
Entering a function manually is the most eflicient way, if you know the exact
syntax of the function, that is how many arguments it requires, the sequence of
arguments, etc. Excel always converts the function you enter into uppercase. I/
Excel does not conuert the function name into uppercase, it indicates that tlrcre is an
error in the function, magbe it has not been spelled conectlg.
- Functions
Microsofi Excel jl'jl'tt 39
Function Wlzard
The second way in which you can enter a function is by using Excel's
Function Wizard. The function wizard ensures that the function is spelled
correctly, and has the appropriate number of arguments.
Formular
.,,.
Dutu.. Re
o Press SHIFT + F3
a Function Wizard can be started by clicking on Formulas and then
selecting the appropriate function category from the ribbon :
The Function Wizard dialog box appears (Fig. 5.1)
This dialog box shows the different categories of functions available in Excel.
When you select a category, the Function Name box displays the functions in that
category.
When a function is selected in the Function Name box, the name of the
function and a brief description of this function appears in the dialog box.
The student is advised to practice the topic on Excel functions by using the
functions directly in the formula bar.
lnselt Fttnctirrn
f- q" --l
Most Recently Used
Returns the number of days between two dales basad on a 350-day year (twelve
30-day months).
OK Cancel
1. Database functions
2. Date and time functions.
3. Engineering functions.
4. Financial functions.
5. Information functions.
6. Logical functions.
40 t"t"tt' Computer Sgstems andApplications-T.Y-B-Com.-(Sem. VI)
1 Country City
2 Dollar USA DC
3 Yen
4 Pound London
5 lndia New Delhi
6 Dinsr Bahrain Manama
7
& Csuntry
9 CitY
"""'."".""""':&*
Country
City
Curency
ffg. 5.5 : To lllustrate the ure of HLOOKUP function
In cell86, type the formula : =HLOOKUP(B9, B1:F3, 2, FALSE)
In cell 87, type the formula : =HLOOKUP(B9, B1.:F3, 3, FALSE)
If the user t5rpes Yen in cell89, cell B6 shows Japan and ceII87 shows Tokyo
CONDITIONAL LOGIC FUNCTIONS
. Excel has several logical functions that enable you to test cells and perform
different operations depending on their contents.
IF
h.trpose :
Rehrrns one value if a condition you speciff evaluates to TRUE
and another value if it evaluates to FALSE.
Sgntax : IF(logical-test, value-iltrue, value-iffalse)
The IF function takes three arguments. the first argument is a logical test
that must be either TRUE or FALSE. The second argument is the formula's result
if the first argument is TRUE. The third argument is tlle formula's result if the
frst argument is FALSE.
Example 1:
If cell A1 contains a number greater than 0, the following formula returns the
result Positiue and returns the value Negatiue otherwise.
=IF(AI > 0, "Positive", "Negative")
Here is an example using the IF function to calculate the sales commissions.
In this example, the normal commission rate is 5o/o of sales. If the sales
representative exceeds the sales goal, the commission rate is 6.5%.
A B c
1 Sales Goal 150,000
2 Commission Rate 5.00%
3 Bonus Rate 6.5Oo/o
4
5 Sa1es Rep Sales Commission
6 Earned
7 Anjali 150,O00 7,500
8 Deepali 2OO,5OO 13,033
I Dilip 110,000 5,500
Jitesh 95,000 4,750
Fig. 5.6 : lllustratlng the use of IF fuaction.
\ \
44 t'r'f Computer Systems and Applicatiorts - T.Y.B.Com.-(Sen. W
The formula in cell C7 is
=IF(87>salesgod, B7*bonusrate, B7*commissionrate).
It uses the IF function to make a decision regarding which commission rate
to use based on the sales amount. Not that we have named the cells El1 as
salesgoal, 82 as commissionrate, and 83 as bonusrate.
Example 2 :
The following worksheet contains the marks JI oa
UL
obtained by students in an exam. Marks are 1 Name Marks Result
stored in column B. Column C should contain 2. Anjali a7
the result oPass' or "Fail" depending on the
Preeti 69
marks obtained by the student. Passing mark is 3
40. 4 John 31
\ l.
46 l,'t't' Computer Sysfems and Applications - T.Y.B.Com.'(Sem. VI)
,-*-*.^-*.::-,-;; .. ,9-.,
-
1 Gender Age
2 M 19
M 18
4 F 20
5 M 21
F za
F 18
I M 19 I
M 20
F 18
We wish to find the average age of males and average age of females. Data is
available in range A1:B10.
In cell 812, type the formula =AVERAGEIF(A2:A10, "Mu, B2:B1O). In this
formula, A2:A10, oM" means we want to search for all males ("M") in range
A2:A1O and their ages are available in range B2:B10.
Similarly, in cell E}13 type the formula =AVERAGEIF(A2:A10, uF", B2:810).
The average ages are shown in cells 812 and 813. q
.,: ,r:S,i,'; :
Example 2 : L Roll No Marks
A teacher has stored the marks in an exam as follows z 1 46
and she would like to know the average marks of the z 53
students. 5 48
6 ABS
Since we want to ilnore those who were absent in the 7 26
exarn, we assume their marks are > O. In cell B13, type the I 33
formula I 38
=AVERAGEIF(82:81 1,',)=0u, B2:81 1) 10 ABS
LEFT
hrpose : Returns a string of characters of a specified length from another
string, beginning at the lefimost position.
Sgntax : LEFT(text, nurn-chars)
Tert is the text string that contains the characters you want to extract,
Num-clnrs specifies how many characters you want the function to extract.
o Num-chars must be greater than or equal to zero.
o If num_chars is greater than the length of text, the LEFT$ function
returns all of text.
o If num-chars is omitted, it is assumed to be 1.
Example:
i) LEFT ("COMMERCE", 3) returns the string "COM", which is the first 3
characters from the left hand side of the string "COMMERCE"
ii) LEFTfCOMMERCE") returns the left-most character "C" only, since we
have not specified the number of characters and the default is 1
character.
RIGHT
hrpose : Returns a string of characters of a specified length from another
string, beginning at the rightmost position.
Sgntax : RIGHT(text, num_chars)
Text : is the text string that contains the characters you want to
extract, Num_clnrs specifies how many characters you want the
function to extract.
a Num_chars must be greater than or equal to zero.
o If num-chars is greater than the length of text, the RIGHT$ function
returns all of text.
o If num_chars is omitted, it is assumed to be 1.
Examples:
i) RIGHTfTELEPHONE", 5) returns the string "PHONE", which is the first 5
characters from the righthand side of he string "TELEPHONE".
ii) RIGHTfCOMMERCE") returns the right-most character "E" only, since we
have not specified the number of characters and the default is 1
character.
MID
Putpose : The MID function returns specific number of characters from a
text string, starting at the position you specify (ie. It returns
characters from the middle of the string).
Sgntax : MID(text, start-position, number-of-chars)
Text : is the text string containing the characters you want to extract.
Start-position is the'position of the first character you want to extract in text.
The first character in text has start-position = 1, and so on.
a If start-position is greater than the length of text, MID returns "" (empty
text).
o Ifstart-position .is less than the length of text, but start-position plus
number-of-chars exceeds the length of text, MID returns the characters
up to the end of text.
Microsofi Excel- Functions t"jl t" 49
o If start-position is less than 1, the MID$ function returns the #VALUE!
error value.
oIf number-of-chars is less than 1, the MIDfl function returns the #VALUE!
error value.
The following worksheet shows the results obtained for MIDfl function :
Characters M U M B A I
Position of character 1 2 3 4 5 6
iv) UPPER("ARTS") returns the value "ARTS" (no change if all alphabets are
already in capital case)
v) UPPER(A2) will return the value of the string in cell A2, converted to all
upper case
LOWER
Purpose : Converts all uppercase letters in a text string to lowercase.
Sgntax : LOWER(text)
Examples:
i)LOWERfHistory") rettrrns the value "history".
ii)
LOWER("COMMERCE") returns the result "commerce"
ii|
LOWER("CoMmErCe") returns the result "commerce"
iv) LOWER("arts") returns the value "arts" (no change if all alphabets are
already in lower case)
v) LOWER(A2) will return the value of the string in cell A2, converted to all
lower case
PROPER
hrpose : Capitalizes the first letter in a text string and any other letters in
text that follow any character other than a letter. Converts all
other letters to lowercase letters.
Sgntax : PROPER(text)
Examples :
a) Arguments b)
parameters
c) variables d)
None of the above
6. A cell A1 contains the following data: MUMBAI-4OOO2O. We want to store the
PINCODE separately in another column, say column 81. Which of the following
functions is most appropriate?
a) LEF-T(A16) b) RIGHT(A1,6)
c) MID(AI, 8, 6) d) Either (b) or (c)
7. What is the purpose of the COUNTfl function?
a) It determines the number of cells in a range
b) It determines the number of empty cells in a range
c) It determines the number of lilled cells in a r€rnge .
a) A Grade Note
o E
b) B 60 D
c) c 5 7A C
80 B
d) D 7
90 A
i
lANsv.IERsl
I. [True:3
False z 1,2,4,51
III. [(1 -c), (2-c), (3-c), (4-al, (5-a), (6-d), (7 -cl, (8-d), (9-c)]
QUESTTOr{S
I. Write short answera :
1. What is a function?
2. What is meant by the retum ualue of. a function?
3. Explain, with s5rntax and examples, the LOOKUP function.
4. Explain, with syntax and examples, the VLOOKUP function.
5. Explain, with syntax and examples, the HLOOKUP function.
6. What is the difference between VLOOKUP and HLOOKUP functions?
7. Explain the use of IF function in Excel.
8. Explain the use of COUNTIF function in Excel.
9. Explain the use of SUMIF function in Excel.
10. Explain any three string (text) functions in Excel.
I 1. Explain the function that is used to extract characters from the beginning of a string.
12. Explain the function that is used to extract characters from the end of a string.
13. Explain the function that is used to extract characters from any position in a string.
14. Explain the UPPERfl and LOWER$ functions, with syntax and examples.
15. Explain the PROPERfl function. In what way is it different from UPPERfl and
LOWERfl tunctions?
16. Explain the difference between the following functions :
a) SUMfl and SUMIF$
b) VLLOKUPfl and HLooKUPfl
c) SUMIFfl and AVERAGEIFfl functions
17. With the help of an example, explain the use of nested IF statements.
U. What is the result of the following Excel functions?
1. =LEFT(',TYBCOM" 2)
2. =LEFT('TYBCOM', 10)
3. =LEFT('TYBCOM",0)
4. =LEFT("TYBCOM", -1)
5. =LEFT("TYBCOM", )
Microsofi Excel - Functions t?.,," 53
6. =RIGHT('TYBCOM',3)
7. =RIGHT("TYBCOM" )
8. =MID("MUMBAI",3,3)
9. =MID(',MUMBAI" 4,6)
10. =LEFT(A39) & MID(A39, to,l) & MID(A39, 22,t) if cell A39 contains coMpurER
SYSTEMS AND APPLICATIONS
11. =LEN("UNIVERSITY OF MUMBAI')
12. =LEN("")
13. =TRIM(" UNIVERSITY OF MUMBAI ')
14. =LEN(TRIM(' ABC "))
15. =LOWER('SUBURBS")
16. =UPPER("western railway")
17. =PROPER("western railway")
18. =FIXED(123.65, -2)
III. wrlte dowa the fuactlon to achleve each of the followiug taska :
1. To convert the first character of each word of "i love computers" to capital letter.
2. To convert the string "tybcom" into all capital letters.
3. To find the number of characters in the word "processor"
4. To remove all spaces from the beginning and end of the string "mobile phone".
5. To display the first three characters of the word "KEYBOARD".
6. To display the last five characters of the word "KEYBOARD".
7. To extract the characters "TEL" from the word "SATELLITE"
8. To count the number of cells in the range D1:D1o that contain numbers.
9. To count the number of students in the range D1o:D1oo securing "A" grade.
PRACTICAL EXERCISES
1. The following data has been entered in a worksheet.
A B c
I Name Pay DA
2 Bhavika 2100
I Priyanka 3000
4 Nikhil 4000
5 Namrata 1800
In cell C2, the formula =IF(B2*O.4 < 1OO0, B2*O.4, l00O) is entered. This formula is
copied to cells C3, C4, and C5. What values will be displayed in cells C2, C3, C4, and
C5? What will be the formula in cell C5?
2 The following data has been entered in a worksheet.
Explain how to calculate the result in 8ft column. The result is declared on the
following basis : A student is declared as pass if he gets 4O or more marks in each
subject, or the average of the marks is 5O or more. Otherwise he is declared as Fail.
4 In the following worksheet enter the values in column B corresponding to formulas
given in column A.
A B
I India is a great country
2 =LEFT(AI,5)
=RIGHT(AI,7)
=MID(A1, 12, 5)
=UPPER(A1)
5. The marks in six subjects of students is shown in the table below. Calculate the total
marks obtained by each student in all the six subjects, and percentage of marks (up
to 2 decimal places). If total marks obtained by a student is greater than or equal to
240, RESULT is PASS else RESULT is FAIL. Also print the highest aggregate marks
obtained.
A B c D E r G H I J
1 Name English Hindi Eco BK Maths Acc. Total Pctg Result
2 Anjali 76 63 78 66 68 86
3 Rajesh 54 49 48 52 46 59
4 Prerana 72 69 66 78 75 81
t, Jasmine 87 73 84 82 91 93
a Mumtaz 54 49 28 31 17 21
7 Highest Aggregate Marks
Also compute the average marks in each subject, excluding
absent scores, ifany.
500
These averages for each subject should appear in row 8.
6. In the above example, create one more column (K) which will
compute the grade of each student, by using nested if 300 - 359
statements. Grade is calculated as per the following table : F < 3fi0
t't'lr'
Aduance d Mbrosofi Excel-Functions
t't,"t' 55
ODULE III
DVANCED MS-EXCE
Arguments : None
Example : = TODAY( ), (in mm/dd lyyW format)
Output : 10/15/2013 (Assume this is today's date, as per the
computer system)
Example ' =TODAYfl+1
Output : 10116/2013
Example : =TODAY()-7
Output : 1.O/8/2O13
NOW
htrpose : Returns the current date and time
Sgntax : NOW o
Arguments : None
Example : = NOWO,
Output : 1O/l5l2ol3 Ll:23
DATE
Purpose : Displays a date based on its three arguments.
Sgntax : DATE(Year, month, day)
56 t"9't. - T.Y.B.Com.-(Sem. VI)
Computer Systems and Applications
STATISTICAL FUNCTIONS
Name
COUNTA Amita
Pooje
Purpose : This function counts the number of cells that are
not empty and the values within the list of sneha
arguments. It is used to count the number of cells Prerana
that contain data in a range
Deepa
Sgntctx : COUNTA (value1,value2,...). Here, value, voh)e2.,,, Maniu
are values that we want to count.
Examples : Consider part of a worksheet as shown below: Geeta
Name
COUNTBLANK Amita
htrpose : This function counts the number of Pooia
Blank cell
empty cells within a range. sneha
Sgntax : COUNTBLANK(range). Prerana
Blank cell
Examples : Consider part of a worksheet as
shown below: Maniu
In cell A16, we have used the formula Blank cell
=COUNTBLANK(A2:A14). This returns the value 6eeta
Blank cell
5 as there are 5 non-erripty cells in the range Seema
A2:A74. Blank cell
a
5
Fig.6.2
CORREL
Htrpose This function returns the correlation coefficient of two ranges.
Use the correlation coefficient to determine the relationship
between two properties.
Sgntax C O RRE L(a r r ay l, arr ay2l
E tr
1 D*tat Data2
2 9
3 7
4 t2
15
6 t7
7
o.98703r coefficient of the two data sets above
Fig.6.3
Cell A8 contains the formula =CORREL(A2:A6, 82:86). The result of this is
shown in cellA8.
LARGE
Purpose ; This function returns the k-th largest value in a data set. This
function can be used to select the first, second, third, or say, the
10th position in a list of
numbers. mrlsictD
1 Datal
Sgntax : LARGE (array, k)
Examples : Consider part of a worksheet
4
as shown below:
5
Cells A2 to A9 contain the data. In cell A1O,
we have used the formula =LARGE(A2:A9, Ll. 7
This returns the largest value (1 = "first', i.e.
maximum value) in the range. In cell A11, the 2t no
formula is =LARGE(A2:A9,2); this returns the 11 Second
value 16 as it is the second largest number. Fourth no
Can you guess what formula is used in cell
At2? rtg.6.4
Remember, in the formula, k should always be greater than zero.
S}IALL A B]C D
OBJECTTVE
I. State whether the followlng are tnre or false :
1. NOWfl function returns.only the current system time.
2. WEEKDAYfl returns the day of the week such as "Sun,, "Mon", etc
3. COUNTA and COUNTBLANK functions applied over a range, will always return the
same value.
Dxcel-hnctions
Aduanced Microsofi t"r.jo Sg
4. The Stt' largest number in a range is obtained by using the formula =LARGE"
. (array, 5).
5. The largest number in a range of 10 numbers can be obtained by using the formula
=SMALL(array, 10)
U. Uulttple Choicc Qucrtloan
Sclect thc mort eppropd.tc dteraetlvc from anoagst those given aad rewrlte
tbe acatencc :
1. The _ function obtains its time and date from the computer's clock :
a) ToDAYfl b) Nowfl
c) CURRENTfl, d) DAYS3600 ,
2. The function gives tJre correlation between two sets of values:
a) I-ARGEfl
- b) COUNTA$
c) COUNTBLANKfl, d) CORRELfl
3. In a range consisting of 1O numbers, which of these formula will return the Sth
largest number?
a) LARGE (A1:A5, 5) b) LARGE (A5:A10, 5)
c) I.ARGE (A1:A10, 5) d) LARGE (5, AI:A1O)
4. In a range consisting of 1O numbers, which of these formula will return the largest
number?
a) SMALL (A1:A10, 1) b) SMALL (A1:A10, 10)
c) SMALL (1, A1:A1O) d) SMALL (lO, A1:A1O)
ANSWERS
I. [Tnre:4, 5
Ealse:1, 2,31
il. [(1 - b), (2 - d), (3 - c), (a - b)l
QUESTIONS
III. Wrlte rhott enltGts :
l. Explain the DATE function in Excel.
2. Explain the DAYS36O function in Excel.
3. Explain the diflierence between TODAY$ and NOW$ tunctions.
4. Explain the dilference between the following functions :
a) Now0 and TIME0
b) DAY$andWEEKDAY$
c) COUNTA$ and COUNTBLANK$
d) LARGE$ andSMALL$
fV. What ls the rerult of the followtag Excel functloas?
l. =DAY("8 JULY')
2. =DAY("8-7-2ol4"l
3. =MONTH("8 JULY'r)
4. =TIME(15,45,1O)
5. =TIME(15,45,)
6. =WEEKDAY("8-JULY-2014')
7. =YEAR("8-JULY-2O14")
8. =DAYS36O("12-OCT-2O13','30-OCT-2O14")
V. Wrlte dosn the fuaetloa to echleve each of the foltowlng tasks :
1. To find the current date.
2. To Iind the current system date and time
3. To find the weekday of26trt January 2OL4.
60 t'r't' Computer Sgstems and Applbations - T.Y.B.Com.-(Sem. VI)
PRACTICAL EXERCISES
1 The dates of births of five employees in an organisation is given the following table.
Write appropriate formula to compute the number of completed years, months and
days (as of today) in columns C, D, and E respectively.
A B c D E
1 Name DOB Years Months Days
2 Aishwalya o2-o4-1975
3 Rajesh t6-o3-t977
4 Prerana 15-O1-1992
5 Jasmine 23-O8-1980
2. For the following set of data, find the largest value in column A, smallest value in
column B and the coeflicient of correlation between the values in columns A and B.
A B
I Datal Dsta2
2 19
3 12 z
4 L7 72
5 L8 15
5 9 1
7 15 7
I 13 5
I 16 9
t?'t'
Microsofi Excel Data Analgsis lt't'l,' 61
7 Microsoft Dxcel
Data Analysis
FILTERING DATA
Filtering a list means hiding alt the rows except those that satisfg a particular
condition. For example, if you have a list of qtudents, do1rg with their percentages
and result (pass/fail), you can filter the data to show only those who have passed
the examination.
Excel provides two ways of filtering data :
o AutoFilter, for quick and simple filtering
o Advance Filter, for more complex filtering.
AutoFilter
In the following example, we will first see how to use the AutoFiltering
feature, which, for most problems is sufficient.
The table below shows a list of names of students, along with their
percentages and Result.
We wish to filter the list so as to view only the results of those who have
passed in the examination.
A B c
Name Percent6ge Result
Anita 69 Pass
Shweta 7? Pass
Mansa a2 Pass
Roopsl 53 Pars
6 Jiten 32 Fail
7 Deep 37 Fail
I Firdaus 40 Pass
61 Psss
E Fail
67 Pass
W.7.2: Fllter buttoa
Fig. 7.1 : Uallltered List
lodAtoZ
Sq*ZtoA
B SoG 5t Colot
I ,Narne tr Percentageffi Resukf !lE# rat$ Fr6fl!'gelait'
\
62 jl"3?' Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
11 67 . P?rs,
f- s *l l" -t r!.!t -l
Fig. 7.5 : Unllltered , List fig. 7.6 : Tert Filter Dldog Bor
Custonl AutoFiltet 7ilE
N6re - ...
begins with
Oq
A I
I Name Resul[i
Mansi 8Z
f**i;K-'l f cq.d -l Pass
29 Fai!
i19.7.7 : Custom Auto-Fllter Dlalog Bor Ftg. 7.E : Elltercd Llat (ltrrt letter M in namc!
I
Microsofi Excel Data Analgsis g?'t'' 63
To Fllter the List :
1. Click anywhere in the list.
2. Press CTRL + SHIFT + L
3. Click on the drop-down arrow that appears in the Name column.
4. Click on Text Filter and select "Begins With..." The Custom AutoFilter dialog
box shown in Fig. 7.7 appears.
5. In the Name begins with, type M, and press OK. The following filtered list
appears; it shows only those students' data whose nzunes begin with 'M'.
(Fig. 7.8).
GRAPHICAL REPRESENTATION OF DATA
Excel's formatting and data interpretation features are extensive. However,
data is often better displayed in a graphical form. One of the most important
features that Excel has incorporated its ability to create'charts and graphs. This
chapter discusses how to create and edit graphs in Excel. At the end of this
chapter, you should be able to :
o Identify the various parts of a chart.
o Identiff different types of charts.
o Create charts from the data.
o Modify the charts.
OVERVIEW OF CHARTS
Charts can be said to be a graphical representation of the numerical data
that can be seen on a worksheet. Just as a pidure is utorth a thousand words,
similarly, a chart can bring out the salient features of data in a worksheet. It is a
sort of "at-a-glance" to the vast amount of numeric data. Data displayed on a
chart is more easily understood. A chart helps us to spot trends and patterns
uthichutould be nearlg impossible to identifg in a range of numbers.
Placing the chatt
When a new chart is created, it can either be inserted directly into the
worksheet (embedded chnrt) or it can be on a new chart sheet in your workbook.
A chart sheet is different from a worksheet in that it can hold a single chart, and
it does not have cells.
Chatt IYpes
Excel offers many chart types. These are: column chart, bar chart, line chart,
pie chart, XY chart (scatter), area chart, doughnut chart, radar chart, surface
chart, bubble chart, stock chart, cone, pyramid and cylinder charts. We will be
studying in detail only the column, bar, line, and pie charts.
Whieh Chaft type to use?
Since Excel offers so many different types of charts, the question that arises
is which chart type is suitable for a given set of data. Try different chart d4pes,
and use the one that puts the message across unambiguously.
Let us see the salient features of different chart t5pes :
1. Column Chart : A column chart shows data changes over a period of time or
illustrates comparisons among items. Categories are organised horizontally,
and values vertically, to emphasize the variation over time.
2. Bar Chart : A bar chart illustrates comparisons among individual items.
Categories are organized vertically, values horizontally, to focus on
comparing values and to place less emphasis on time.
64 t"t'j" Computer Systems andApplications-T.Y.B.Com.-(Sem. VI)
3. Stacked bar charts show the relationship of individual items to the whole.
4. Llne Chart : A line chart shows trends in data at equal intervals.
5. XY Chart : An XY chart either shows the relationships among the numeric
values in several data series or plots two groups of numbers as one series of
riy coordinates. It is commonly used for scientific data, such as variation of
temperature with time.
6. Ple Chart : This chart shows the proportional size of items that make up a
data series to the sum of the items. It always shows one data series; it is
used to emphasize a significant element.
CREATING SIMPLE CHARTS
Creatlng a Column Chatt
t Sal€ of
4
Sublect
Accounts
Taxation
Mumbai
247A
27!n
Pune
2W
2t7t
Nagpur
2388
aJ71
I
gsk
6 BUs. LarU 2893 27:t2 1905 Column lins Pie Bar Area scatter Other
7 Total 8161 75*' Glm
Flg. 7.9 : Sample wortshect Flg. 7.1O : Cbail Typee ln Ercel 2OO7
The following worksheet shows the number of books of different subjects,
sold in three cities Mumbai, hrne and Nagpur :
Step I : Create the Basic Chart:
We create a basic chart based on this data as follows :
1. Select the range A3 : D6. This can be done by either of the following ways :
a) Click on cell A3. Keep the SHIFT key pressed and click on the diagonally
opposite cellD6. The complete range is highlighted.
b) Press the function key F5. In te GoTo dialog box that'pops up, in the
reference text box, type A3:D6. The entire range is highlighted.
2. Click on Insert tab.
3. In the ribbon, click on Column button in Charts group. (Fig. 7.I0)
4. various chart types are shown. select the first option, i.e., 2D column )
Clustered Column.(Fig. 7.11). Excel ceates a Clustered Column chart and the
Chart Tools context tabs appear.
5. The basic chart created by Excel is shown below (Fig. 7.12) :
35{X'
300
2t0J
am IAc<ounts
15{X' I Tilatbn
S Bus. Le
tqx,
5tx,
tE[ H[ o
Mumbai Fune laigpur
Fig. 7.11 : Selecting 2D Columa Chatt DlS.7.l2: Baslc 2D Cluetered Column Chaft
Microsofi, Excel Data Analgsis t"3l";1" 65
Step II : Apply a Chart Layout :
Once the basic chart is created, we can change the chart layout and display
the chart tifle, legend, axes labe1s, etc.
l. Click the chart as shown in Fig. 7.12 above. The Chart Tools becomes
available on top of the Excel menu.
2. Choose the Design tab.
3. Click the Chart Layout button in the Chart Layout goup. (Fig. 7.13)
4. Click layout 5. Excel applies the layout to the chart. (Fig. 7.1a)
Title
I! I
J
-
!
2500
2(xx)
I
I--
a
150(}
6
10@
500
0
Mumbai Punc l&pur
IA€counts 2478 2&A 2388
I Tildtion 2790 2173 2077
I Bus. law 2893 2?22 19(,5
Chart Title
Gridline Sale of Books
35aX' Plot Area
:xx,o
2500
u 2(m
Axis Title E
it 1900 Selection Box
1(m
Value Axis
A{cqnb + Tu&a E{8. Lt
a Mumb.i 2414 279' 2895
Legend lPun€ 2go 2173 2722
: Nngpur 238r m77 lgr5
Category &ris
ELEMENTS OF A CHART
Before we discuss charting in further detail, let us see the different elements
of a chart. Different types of charts have difrerent elements - for example, pie
charts do not have axes, and only 3D charts have walls and floors. (FiS. 7.281
The various chart elements are described below :
1. Gridllne : These are lines you can add to a chart that make it easier to view
and evaluate data.
2. l*gerrd : It is a box that identifies the patterns or colors assigned to the data
series or categories in a chart.
3. Plot Area : The area where the actual chart is plotted, excluding the legend.
4. Title : The chart's title.
5. Data Serles : It is a group of related data points plotted in a chart that
originate a from rows or columns on a single worksheet. Each data series in a
chart has a unique colour or pattern. You can plot one or more data series in
a chart.
6. X-Arls : This is called the "Category axis". This axis represents the different
categories that are plotted on chart.
7. Value Arls or Y-aris : This represents t}re ualues of data points.
8. Category Names : The names are taken from the topmost row or leftmost
column of the worksheet.
9. Data Markers : It is a bar, a dot, or some other symbol in a chart that
represents a single value that originates from a worksheet cell.
10. Tick Marks : These are small lines of measurement that intersect an axis,
similar to divisions on a ruler.
MANIPULATING THE CHART
An Excel chart can be moved, changed in size, deleted, etc.
1. Changing the chart slze : To change the size of a chart, click on the chart to
select it. Small selection boxes appear on each corner of the chart. Drag one
of the selection handles to make the chart larger or smaller.
2. Movlng the chart : To move the chart, press the mouse on the border of the
chart and drag the mouse.
Analysis
Miirosofi Exrel Data t'jPt' 67
3. Deleting a chart : Select the chart and press Delete or Backspace to delete
it.
4. Changlng charted date : Charts are linkla to the selected data. Whenever
the data changes, the chart adjusts to reflect those changes.
EXCEL'S CHART TYPES
Having studied the fundamentals of charting through Excel, let us now draw
different types of charts. The column chart has already been covered earlier in
this chapter.
BAR' CHART
A bar clurt rls essentiallg a column chart ttnt hns been rotated bg 90 degrees.
The advantage of using a bar chart is that the category labe1s may be easier to
read. Bar charts can consist of any number of data series.
Exanple:
The following table shows the loans disbursed to individuals by a housing
finance company. Plot a bar chart for the data. (Rupees in crores)
LoansDisbursed
zfii{g
a
C
t I*rie51
B I 20da{t8 840
I-
Loans Oisbursed I
2006€7
Lrc
3896
Sub:idiaries
c D E 1296
1 Shareholding Pattern by Various lnstitutions
2
3 UC
4 38% 12% 15% 12% 23o/a 15}6 Lzy6
Fig. 7.19 : Data to plot a Ple Chart Ftg. 7.2O : Pie Chart
Steps to plot a Pie Chart
1. Select the data in the range A3: E4.
2. Click on Insert.
3. In the Chart group, click on Pie and select 2D Pie. The basic chart is created
4. In the Chart Tools, click on Design tab.
5. From the Chart Layouts group, select the first type Layout 1.
6. In the chart, click on the Chart Title and type Shareholding Pattern.
7. In the Chart Tools, click on Layout.
8. In the Labels group, click on Data Labels ) Outside End.
The completed graph is shown in Fig. 20.
LINE CHART
Line charts are very common. They are frequently used to plot data that is
continuous rather than discrete. For example, plotting daily price of a share or a
mutual fund may let you spot trends over time.
Example:
Consider the table shown below which shows the daily rainfall in two towns
for a twelve month period. We have to plot a line chart for the data in this table.
Jan Feb Mar Jun Jul Aug Sep Oct Nov Dec
TownA 25 11 1S 10 331
Torn B 5 78 19 21 15 11
20
\
{
\ lr
?15 /\ \
E / / \ \
€ro
\ -TownA B
5
/ \ \ -Tosnl
,/
0
J.n hb Mlr Apr Mry Jun Jul Aui 5.p Oct tla. O.c
Fig.7.22: Llae Chart
GUIDELINES FOR PLOTTING CHARTS
Excel has excellent charting capabilities, and all these cannot be covered in
this text book for lack of space. The interested student is encouraged to
experiment with different types of charts for a particular data. Here are a few
guidelines for plotting charts.
1. Are the data that you want to plot in two rows of the table or in two
columns?
If the data are in columns, select two columns for plotting :
O if the columns to be plotted are not adJacent to one another, you must
click on the top of the first column on the letter of that column (for
example, column A, or B, etc). Then press the CTRL key and click on the
top of the second column on the letter of that column.
O if the columns to be plotted are adjacent to one another, you must click
on the top of the first column on the number of that column. Then press
SHIFT key and click on the top cf the adjacent column on that column's
number.
If the data are in rows, select two rows for plotting :
O if the rows to be plotted are not adjacent to one another, you must click
on the left of the first row on the number of that column. Then press the
CTRL key and click on the left of the second row on the number of that
row.
70 t"r'jl' - T.Y.B.Com-(Sem. VI)
Computer Systems and Applications
O if the rows to be plotted are adJaceat to one another, you must click on
the left of the first row on the number of that row. Then press SHIFT key
and click on the left of the adjacent row on that column's number
2. Excel offers many different types of charts. Use the one which makes the
values of your table easily understood. Don't use an esoteric chart type just
because it is there!
3. If you have constructed a chart, you can easily edlt any element of the chart
by double-clicking the element. A dialog box relevant to that element will open
up, and you can make changes to it.
USING SCENARIOS. CREATING AND MANAGING A SCENARIO
Scenarios are part of a group of commands sometimes callpd what-if
analysis (what-if analysis is a process of changing the values in cells to see how
those changes affect the outcome of formulas on the worksheet). A Scenario is a
group of values that give different results when involved in a calculation. They are
widely used in budgeting to determine how change in values e.g. increase
expense on raw material will affect the overall future budgei of the company. The
Scenario Manager can be used to put different values in and generate different
budgets for each set of values. The Scenario Manager is available in the Data Tab
under What-If Analysis.
,*im;r
.l{ i 5o* nter
:#F3
Text t6 RemoPc
ffi Data
.p advanceo Columns Dupli(ntes V;lidation -
F H, .J lt Oata Iable.,,
li rdd^-. . il
f.wr...I
(}tllUilgidr:
CaElt€rb
f.,, ;
w.7.24
This is where the scenario can be created. By clicking on Add we can give the
scenario a name e.g. Budget, then enter the cells range which contain the values
e.g. A5:A15 that can be changed to produce different stenarios.
Microsoft Excel Data Analgsis
t'r?' 71
Scrbqane:
BrdgEt
dffigirry!ds"
CgnrylEnL
Created by Faiyaz m 18115l|S 14
ProEctftm
Mnrellern*ange
tsr*
fl( ,,,',,,;{crd
10
Prepare scenarios where there is an increase as follows :
0 Machinery increases to 80,000, Carriage increases to 9O0O and Postage
increases to 8000
ii) Carriage increases to 10000, office equipment increases to 7000 and
Postage increases to 90O0.
Solution :
1. From Data Tab select What-If Analysis and then select Scenario Manager.
2. Click on Add in the scenario manager and in the scenario dialog box type
Current Expenses.
3. In the changing cells type B2:B8 and click on ok.
4. Again click on Add in the scenario manager and in the scenario dialog box
type Increase in Machinery and Carriage and click on ok.
72r'r?.ComputerSystemsandApplications_T.Y.B.Com.y'Sem.W)
S. In the scenario values dialog box ffie in Machinery Text box $B$2 type
80000
6. In the carriage box $B$3 type 9OOO.
7. In the Postage box, $8$6 type SOOO and click on ok
8. Again click on Add in the scenario manager and in the scenario dialog box
type Increase in carriage and office equipment and click on ok.
9. In the carriage box $B$3 type 1OOOO.
1O. In the office equipment box $B$5 type 7OOO.
1 L. In the Postage $B$6 9OOO and click on ok.
&..
Q*!
E*r,.
Ulrnr.,,
ql'trrry,,.
chmfigc*&r 18$2:18*8
Cqtlnrrltr fdt olL9rs1{
$o{ {lm
w.7.26
L2. In the Scenarid manager dialog box click on Summar5r
13. In the Scenario Summar5r dialog box select Scenario Summary, t5pe 89 in
the result cell and click on 6k.
14. The Scenarios are displayed on a new Scenario Summary Worksheet.
15. Select A1:A8 and select copy.
16. Select A5 in the scenario summary and click Paste. The following scenario is
obtained.
c 0 T T
ffi
rm $il
sfi|0 3sm
60m 6m
Im sm
s lmo
D19.7.27
Microsofi Excel Data Analgsis t'0't' 73
GOAL SEEK
Using known values we can perform calculations using Formulas and
functions to obtain the required answer. This is very common and we have used
it in several examples. However, sometimes we may know the answer (goal), but
we do not know the value to be used in the formula to achieve this goal. Goal
Seek option is available in the Data Tab under What-If analysis.
Dtta
h
ffit
$
;iHE
*oaio*
Propertie:
Edit LinkE
f,
x I iaizt
z
A
lzlrl
I
-
Sort
Y y:*'
tl
m.r -
Keappry
Irfikt(r€
BE.E H
Ttrtto Rrlrwr lldi
Cohmar Duplicdts Vrltuldion.
*
(onsoliddr
qH qH
Group Ungroup Subtoti
Bffi
@lSccl..
tla$ISle,,,
C
Ftg. 7.31
Further using Goal Seek find the projected growth rate in 2ll5 to achieve a
target value of 10,00,00,000.
Solution :
DA
1. Select C2 and type =B2*1.O0 and press enter.
2. Select C2 ar:d drag the fill handle to C6.
HRA
1. Select D2 and type =IF(E!2<=5OO00,Fl2*.33,82*.25) and press enter.
2. Select D2 and drag the fill handle to D6.
GROSS SALARY
1. Select E2 and, type = SUM(B2:D 2l and,press enter.
2. Select E2 and drag the fill handle to E6.
Microsofi, Esrcel Data Analgsis l,'t?' 75
PROJECTED GROWTH RATE
1. Select C10 and type =C8*C9 and press enter. (This will calculate the
projected Sales once Goal Seek has obtained tl.e growth rate in C9).
2. Give cell C9 the percentage format with 2 decimals.
3. In Data Tab select What-If analysis and then select Goal Seek.
4. In 'Set cell't5ryeC10.
5. In 'To value'type 1O00OOOOO.
6. In By changrng cell'qpe C9 and click on ok, the goal seek status dialog box
indicates it has found the value, click on ok, the overall required growth rate
'is obtained in the cell C9. Subtract 100 from the growth rate shown to obtain
the growth rate necessary to achieve this projected sales.
D E
9 I
w.7.32
SOLVER
Solver is a What-If analysis tool, which finds t}:e optimurn value in a target
cell by changing values in cells used to calculate the target cells. Hence, when
two or more unknown values have to be determined, Solver can be used: Goal
Seek is.used when there is only one Unknown valui to be found. For example let
us assume that a sale of t 5,00,O00 has to be rrade of three different products if
a company has to break even. Then, using solver we can determine how many
units of each of these three products should be sold, so as to achieve required
goal of the sale amount of ( 5,OO,OO0.
Solver is an Add-in and is found in the Data Tab. If it is not visible.in the
Data Tab it indicates that it has not been insk^lled. To install it, select bptions in
the File Tab and then use the add-in option. ,.,-
Enample: ,'
A Company makes threb products Bats, Racquets aird Footballs whose sale
price is t 3OO,-< 200 and t 15O respectively. For the'company to break even, it
haS to achieve a total sale of t 5,OO,OOO in a.yei1r. U-"hq Solver,- find out the
number of units of each of these three products that should be sold in ofder to
meet the desired target sale.
Solution:
1. In A1 type 300, A2 type 200 and in A3 type 150. I
2. type O-ih the cells e1,eZ and B3.(Solver will entef ttre quantity to be sold of
eachof these 3'products in these cells.
3. 'seleit Cl and !5pe =A1"B1 (here we are aqking Excel.to multiply the selling
price per unit with the qrrantity sold in order to obtain sales val-ue.)
4. , Select Cl and drag the fill handle to C3.
S. Select C4 and t5pe =SUM(CI:C3). This is ttre total salqs to be achieved.
6. In Dl type Bat, D2 t5rpe Racquit and in D3 type Football. -
; . il; 6i;; i';r" ,h; pata rab 1"r."-is"rrJ.l --\ _
.l
i.
A. \
76 t't'r' Computer Sgsfems and Applications - T.Y.B.Com.'(Sem. VI)
s..-f 'r..
m Y {:;,,
yffi
ffist E *
rdr. tffi
(MrW&.
& <@,{
ffi
S'
.IEl
u
.j9
q4ryryud
Sti .:
-
,..:." tle
w.r*Bt@rtdfb6k
F dYtud.rddry
ffirerh(*u.dto
1 300 o 0 BATS 8sE
0 O:RACQUETS
0 FOOTBALL
0
rt9.7.33
8. In the dialog box in the 'Set objective'option the cell C4 rs already selected.
9. In the To'option there is Max, Min and Value. Max is selected when you
' want to increase the goal to the largest value, if Min is selected it decreases
the goal cell to the smallest value. Select Value of and type 5000OO in the
text box.
10. In the option tsy Changing Variable cells'text box enter B1:B3.
QyChrldtErrr*tltr
BLA3 &r
*Ftcctbf:ffi
ahiltcc
ee
&l!rl'taf
loadEn,G
ts rr{r ursr***g tEier }ar}qrnrG
Sclcdasoa*qtit rto* GRGilalr:{ Atrc
SdiEr+f,rod
<dca tr: GnG frctrcr Gq|ir tu SdtE ffit ftda adr naftr. *d trc t'P #a
tqir fr. hcr Sohc pnd:sr+ adrdcd*aFderyatne fri Sdrcrrollrr *ratre
ffi
FlA.7.34
11. Then click on Solve. When Solver will obtain the result, click on ok.
7 *H.&atuilrdffi&&
8 rbe64EuI€,kBM * r.&. hr*@r
sr'e Y696&p ts@,sanaE$EMr hd.rt6l
9
Fi9.7.35
Microsofi Excel Data Analgsis t't't" 77
12. Round the numbers in Column B by using the decrease decimal option from
the Home Tab. These are the required number of units of each of the three
products that have to be sold in order to achieve the sales goal of t 5O0OO0.
Example:
A Company makes four products Printers, LCD Monitors, Keyboards and
Hard disks whose sale price is { 5000, < 3OOO, t 1000 and t 3500 respectively.
For the company to break even, it has to achieve a total sale of { 1,O0,OO,O0O in a
year. Using Solver find out the number of units of each of these four products
that should be sold in order to meet the desired target sale, given that the
Company has the capacity to make maximum 2000,1000,3000 and 1800 units of
each of these four products respectively in a year.
Solution :
AilRs{atrc: (00fk*tt
<- l0G0
0( Crrd
Ftg.7.36
12- In 'Cell Reference'type B1 and in constraint type 200O and ctrick on
Add.
13. In 'Cell Reference' type B2 and in constraint type 1O00 and click on
Add.
14. In 'Cell Reference' type El3 and in constraint type 3000 and click on
Add.
15. In 'CelI Reference' type 84 and in constraint type 1800 and click on
ok.
78 ,'t't" Computer Systems and Applications - T.Y.B.Com.-(Sem. V,l
t lobfirtc:
To: ,:13n Sat {t l*rG ,omqm
S(,rc!0lf r*ccar
18*r3i4
SgFdc.t b th. Cdl*A.inB.
F*1 <*4rc
<*18
#
{*ffi
<- llID
ge
&B.tlf
SdYifSd
s& t: GnGtffiE gtgi: fu sduGt *rd4 tr*rt sdr rs*rs. sd.d [t! It Hs
.'TE fu trlrs*rs E&t, ild.{t*CtE *6o$ry.'t*. fu sdvr frfu t*t rt
rE#r.
tdrre
?8 7.37
16. Then click on Solve. Wheii Solver will obtain the result, click on ok.
17. Round the numbers in Column B by using the decrease decimal option from
the Home Tab. These are the required number of units of 'each of the four
products that have to be sold in order to achieve the sales goal of
{ 1,O0,OO,OOO.
UNDERSTANDING MACROS
The word 'macro' means an action or a set of actions that 5rou can use to
automate tasks. Macros are an advanced feature of Excel that can speed up
editing or formatting you may perform often in an Excel worksheet. They record
sequences of menu selections that yciu choose so that a series of actions can be
completed in one step. Macros can be used to automate many. tasks in a
spreadsheet - format 'document, insert formulas in cells, perform repeated
calculations, etc. Macros are available in all Microsoft Office products such as
Word, Excel, PowerPoint but we shall study macros only for use in Excel. Macros
use a language called Visual Basic for Applications (VBA) which is similar to
Visual Basic.
The macro feature may not be available by default in Excel. Click on View
and you should be able to see the Macros option in the View ribbon. If the Macros
option is not available in View ribbon, do the following :
Microsofi ExcelDataAnalgsi"s ,"t t, 79
!s
3 na(rostr$rx '@
& Qpen
e s(emriol,xls
3 Xi-Tarminnldrtr-Marrthi.xlfl
&
-{,i{
H sa}?
R SaE As )
Esi t
*
w PrgEre )
ry l?nd )
:ry Pgbiirh )
Gd Elorr
ETffi
.=[:::
t:5\irtf x qit
[xcel Oplions
q6rya&,!*w-;
ffilffirei
Formuhr
Proofing
Aalvan(cal
Curtomize
Resour("s Create lirts for u'e in torts and titl 5equenc€r: Fdil fil(tom I idr..-
rrg.7.39
To set the security level temporarily to enable all macros, do the following :
Developer
2. Under Macro Settings, click Enable A11 Macros (not recommended...) and
click OK.
Trusl Centel
Trusted Publishers
ilxro sdtfr}lF
TruJted Lo6tions
For ma(or an do(UlrlCntt not in a trutted iocatiotx
Add-ihs $ Oi:able a1t maaos without notafiGtton
Adiv.X Scttingr
0 plsablr rli Eta('or with notifiEation
0 Disable all maffos crcept digitatty signcd mafiot
o
Mcsrag€ Bar Dcr.elop€{ Uico s€ttingtr
External Contcnt
I Trust accer: to the VBA projed objeEt model
Privary Optionr
flt li T
ldH
Zoom 100% Ioomto
:rr,t
.'
*i
J
New
-ttt
!
I
An*ngr Free:e
!.U
tr:ptit
-!Hide
: _lj iier, ltdr rI tidt
,.: i,',:":': . ri:. :' .l
ffim
5x* Switrh
Srlertion Window Atl Pine! * I '. ,l:l '
. :: :' .': :'. :
Wo*lpace Windows'
I{om $rindorJ
H ) Mrl{ 0rP
YV.7.42: Recordiag a Macro A B C
Erample 1: 1 Product Li5t Price Dascount ,Sell Price
Record a simple macro that will create a 2 Hard Disk 40fi) 4000
table as shown below and assign the key 3 Monitor 7800 7SO0
Step 1 : Click on Developer, in the Code group, click on Record Macro and in
the dialog box that appears, type Macro name as Macrol, in shortcut key, type e
(it will effectively become CTRL+SHIFT+Q), leave the Store Macro in as it is
(default value is This workbook). In description, t5pe My First Macro, click oK.
ctrhshifi+S
Workbook
My First Macro
OK Cancel
r"U.7.++
As soon as you click OK in the above dialog box, the macro recording begins.
You can verify this because instead of "Record Macro" you will see Stop recording
in the Code group.
Type the following data in various cells. In cell D2, type the formula =82-C2.
Drag this formula till cell D5. Once all this data is recorded, click on Stop
recording and your spreadsheet will look as shown in Fig. 7.43.
Your macro is now recorded. To veriff this carry out the following steps :
1. In the same workbook, click on Sheet 2.
2. Click on any cell.
3. Press CTRL+SHIFT+Q (keep CTRL and SHIFT keys pressed with one hand,
and with the other, press Q).
4. You will find the same table appears immediately starting from cell A1. This
is the magic of macros!
Running a macro :
We have already run the macro we created. But let us now state the two ways
in which macros can be run :
1. By pressing the key combination that was decided before recording the
macro.
2. By selecting the name of the macro from a list of available macros. We will
now see this second way of running a macro.
Running a macro by selecting macro name :
1. Create a new worksheet in the same workbook. This may be named as
Sheet 3.
2. Click on the Developer tab, and in the Code group, click on Macros. The
following dialog box opens.
82 n't't' Computer Sgstems and Applications - T.Y.B.Com.-(Sem- V0
Macro II IrEl
Ee
(rBate
t-{yF *M{ro
12. C1ick the Stop Recording button on the ribbon to stop the macro recording.
13. Now in a new worksheet, go to cellA1 and type "Income-Expenditure Data for
2014".
14. In the Developer tab, go to Code group and select Macros. Click on Macro 2
and then click. on Run. The text in cell A1 will be formatted as shown in
Fig.7.47.
Microsofi Excel Data Analgsi.s l,'t't' 83
A1 II:
lrr
L_r'
|'Io Fill
More folors,,,
Editing a Macro :
Macros are created in the VBA (Visual Basic for Applications) scripting
language. Thus, to edit a macro, we must be familiar with this language. Let us
take an example of editing the macro we created in the previous example - that of
formatting a range of cells.
Here is the sequence of steps to edit the macro:
1. Keep the workbook open in which we created the previous macro i.e. Macro 2
for formatting a range of cells.
2. Click on Developer menu and in the ribbon, in the Code group, click on
Macros ) Edit.(Fig. 7.a8)
I
Hemr Inrert Farmulas Bata Rerriew Developer
fulacro 2 Ei
F16 "e
B I C D
4 Delate
5
gption5.
7
I mBcros in: All Open Workbook
Des(ription
-*-+ li Format Cells
10 .J
I
Cancel
13
3. When you click on Edit, the Microsoft Visual Basic Editor window opens up
(Fig. 7.ael
'/i Microsofl Visual Basic Bookz
Fgmat Jooli Add-lnr lyindM E.,p
g da t! ir lg. &t'gl iii }*', @
Pr0le{t - t&AProiect
. Book2 Modulel (Codel
YBAP]orcct
Microsof t Excel Obrcctg Format Cells
she6t1 (5h@t1)
Sheetz (5[Eet2)
stEet3 (5[E€t3)
Thiswqkbook Ranqe ( r'41: F1") . SrlecE
Modules IriEh SeIecEion
Modlel .HorizonEallliqment - xlcenter
. VerC icalAl igmenE = x lBottom
.UrapTexE - False
.OEientation = O
.AddlndenE = FaLse
P.opertiei - .fndentl.evel = O
.SttrinkToFit = False
.Readingorder - xLconEext
.I{ergeceILs - False
End lriEh
Se Iect ion. llerge
Irich SeIecEioD. Interior
-PetrFrn r ytSnlid
Fig, 7.49 : Mlcrosoft Vieual Baslc Editor wlndow
4. You can see the VBA code that was automatically created when you recorded
the macro. We will not study this code in detail as it is beyond the scope of
this syllabus. But we will make a few changes in this code and see the effect
when the macro is run. The complete original code is shown below and the
two lines that we will edit are shown in a bigger font and in bold.
Microsofi Excel Data Analgsi"s g't"t," 85
Sub Macro2fl
Range("A 1 ").Select
:F 1
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = O
.Addlndent = False
.Indentlevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
With Selection.Interior
.Pattern = xlSolid
.PatternColorlndex = xlAutomatic
.ThemeColor = xlThemeColorAccentl
.TintAndShade = 0
.PatternTintAndShade = O
End With
With Selection.Font
.ThemeColor = dThemeColorDark 1
.TintAndShade = 0
End With
With Selection.Font
.Name = "Calibri"
.Size = 15
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorDarkl.
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
End Sub
86 ,'t't' Computer Systems and Applications - T.Y.B.Com-(*m' VI)
Versova
do repetitive tasks. Assume you have a worksheet that Mumbai - 4{)Gt)61
contains data as shown in the Fig.7.50 and you want the 5
Dilip shah
A-65, Gita Apartments,
D M G Road
iA
Ahmedabed
1 Mehta Versorra Mumbai- rt00061
2 Hema Jain Park Avenue Bandra Mumbai - rtooO50
16 Prerana S
3 Dili Shah 4-65, Gita M G Road Ahmedabad
l7 1030, SkyTo$rers
4 Prerane S SkyTowers Wadala Mumbai
wadala
OBJECTIVE
I. State whether the following are tnre or false :
l. When data is filtered, it is also sorted in ascending order.
2. The AutoFilter command adds drop-down arrows to header rows.
3. Once drop-down arrows are added to the header row, they cannot be removed.
4. A graph can be created only through the Insert -> Chart option.
5. No modifications can be made to a chart.
6. The chart wizard can create new charts as well as modi$r existing charts.
7. If the data values in a table are changed, the chart also changes.
8. A chart cannot be moved around on a worksheet.
9. The Legend on a chart can be removed.
10. A pie chart can be drawn only from a single data series
1 1. The most appropriate form of chart for continuous data is the line chart.
12. To plot chart based on two columns, the two columns must necessarily be adjacent
to each other.
13. Any number of data series can be used to plot a bar chart.
14. All types of charts can be created through the Chart Wizard.
15. When plotting a chart, the labels for the data should not be selected as they are not
numeric data.
16. Embedded charts can be created directly on a worksheet.
17. Solver and Goal Seek are used for the same purpose in Excel.
18. A macro can be used to automate the creation of a chart.
19. Once a macro is created it cannot be modified.
20. Goal Seek is the process of finding the point where costs equal revenue.
21. Solver problems are limited to a single changing cell.
22. A Scenario uses changing cells.
23. Scenarios allow more than one variable to be changed at a time and automatically
generate a two-variable data table.
II. Multiple Choice Questions
Select the appropriate optlon from the following :
1. AutoFilter feature allows the user to :
a) Copy data that matches a criteria into another worksheet
b) Display data that matches certain criteria
c) delete data that matches a criteria
d) Perform calculations only on selected data
2. Which types of charts can Excel produce?
a) Line graphs and pie charts only
b) Only line graphs
c) Bar charts, line graphs and pie charts
d) Bar charts and line graPhs onlY
3. The chart wizard
a) Can place a chart on a new chart sheet or on any sheet in the workbook
b) Can only place a chart on new chart sheet
c) Can only place a chart on a new blank worksheet
d) Can only be used to create embedded charts
4. What chart object is horizontal or vertical line that extends across the plot area to
make it easier to read and follow the values?
a) Category axis, b) Data marker,
c) Data point, d) Gridline
88 jl"t"f' Computer Systems and Applications - T.Y.B.Com'-(Sem' VI)
ANSWERS
I. [True : 2, 4, 6,7,9, lO, 11, 13, 14, 16, 18, 22
False : 1, 3, 5, 8, 12, 15, t7, 19,20, 2I, 23 |
III. [(1 -b), (2-cl, (3-a), (4-d), (5-b), (6-a), (T -d), (8-c), (9-c), (10-a), (11-b),
(12 -bl, (13 - d), (14 - d), (15 - c), (16 - c), (17 - d) l
QUESTTONS
trIrlte short answers :
PRACTICAL EXERCISES
1. Enter the following data into a worksheet.
Sales Turnover for BNU Enterprises Ltd.
Jan Feb Mar Apr May Jun
Mumbai 50000 60000 70000 75000 75000 70000
Delhi 20000 24000 30000 30000 35000 40000
Chennai 45000 50000 55000 60000 55000 50000
a) Calculate the total values for each row and each column.
b) Calculate the average, max and min values for each row and column.
c) Create a pie chart indicating percentage contribution of total turnover for each
branch.
d) Create a line graph that allows comparison of branch turnover month by month.
e) Enter the values for targets into the worksheet
90 jl'n'jl' Computer Systems andApplications-T.Y.B.Com.'(Sem. VI)
A B c D
Student Exam 1 Exarn 2 Exam 3 Exam 4
Prerana 85 79 77 81
Jenifer 77 73 69 72
Mumtaz 68 69 79 81
Aishwarya 76 77 69 74
Write steps to create following charts :
a) Line chart for each student for each exarn. Consider Students on X axis and
marks on the Y axis.
b) 2D pie chart for E.xarn 2
c) 3D pie chart for Jenifer
5 Create a macro to format the spreadsheet as follows so that whenever the user
presses the key combination CTRL+SHIFT+Q, this layout is created.
IABCDE ti
l- i l,J
STIBJEC {TANCY T
RollNo Name Marks
Font size in row 1 is 14. Choose Font as Calibri. Font size in row 2,4 aurrd 6 is 12.
Row 4 has a Fill Color of 'White, Backgroundl, Darker 25o/o". All fonts are Bold. This
macro should be available only in the existing workbook. List all the steps required
for this exercise.
6 The following table shows the monthly expenditure on different heads and the
income of Mr. Mehta. Use the Scenario feature of Excel to study the effect of reducing
expenditure on Club fees, Internet access and food and how it affects the balance
income.
Microsofi, Excel Data Analysis lt't't' 91
1
Particulars Experditure lncome
Rent 11000 50m0
Food 111000
Phone Bills 500
6 Clothes um
Travelling 30(n
I Club 50m
I lnternet 7tn
10 Books 600
Health Care ili00
L2 EMls 8{no
7. Deepali starts a business and is making a profit of t 25,O00 per montJr through her
e-commerce website. After 6 months she decides to set a new profit Goal of t 35,000.
At the moment, she is selling 1000 items at ? 25 each. Assuming that she will still
sell 1OOO items, by how much should she increase the prices to achieve the new
profit of 35,OOO? Use the Goal Seek feature of Excel.
r'''l,'
\
92 t't't' Computer Systems and Applications - T.Y.B.Com--(Sem. VI)
MODULE I
ISUAL BASI
Introduction to
8 Yisual Bosic
INTRODUCTION
Visual Basic is a programming language that provides tools to create
Windows-based programs. These Windows-based programs have the familiar
elements like menus, text box, label, command buttons, scroll box, etc.
Microsoft Windows operating system uses a graphical user interface (GUI)
and Visual Basic (VB) is an ideal programming language for developing
sophisticated professional applications for Microsoft Windows. It makes use of
Graphical User Interface for creating powerful applications.
The origins of Visual Basic can be traced back to one of the oldest and most
popular programming language of the 1960s and 1970s - BASIC. BASIC is an
acronym for Beginner's Nl-Purpose Symbolic Instruction Code. The earliest
versions of BASIC could be used to develop DOS-based programs only (i.e. no
graphical user interface). Over the years, this transformed into a very robust
programming language called Visual Basic. The word "Visual" implies that Visual
Basic supports a graphical user interface, and common graphical elements like
forms, buttons, check boxes, option buttons, windows, etc.
CLASSIFICATION OF PROGRAMMING LANGUAGES
There are hundreds of programming languages but the most common today
are Visual Basic, C, C++, C#, Java, PHP, Ruby, Perl, Srthon, JavaScript, and
Delphi. Each language is suitable for a particular type of application. For
example, for scientific calculations C, C++ and FORTRAN are very common. For
Internet-based applications Java is popular.
But all programming languages can be classified into three broad categories :
O Procedural Programming Languages : Traditional programming
languages such as C, COBOL, FORTRAN, and BASIC are procedural languages.
The program specifies the exact sequence of all operations. The sequence in
which instructions will be executed depends on the program logic.
O ObJect-Oriented programming languages : g++, C#, Java and Visual
Basic are object-oriented languages and they use the concepts of Object-Oriented
Programming (OOP). An object can be thought of as a collection of data and
methods or functions that can operate on that data.
O Event-driven programming languages : In event-driven programming
languages, programs do not follow a sequential logic. The sequence of execution
is controlled by the user. The user can press a key, click a button, etc. and each
Introduction to Visual Basic l,'l?'t' 93
action causes an euent to take place. This event triggers (i.e., starts the execution
of) a procedure that the programmer has written. Thus, the flow of the program is
determined by events. These languages use features of object-oriented
programming languages.
Event-driven vs Traditional Programmlng
In a traditional or "procedural" application, the application itself rather than
an event controls the portion of the code that execute. Execution starts with the
first line of code and follows a predefined path through the application. Examples
of such procedural languages are C and FORTRAN.
In event-driven programs, a user action executes a procedure. The order in
which the code executes depends on what the user does. Thus in event-driven
programming, the user is in-charge and the code responds accordingly. Examples
of euent are mouse click, pressing a key, releasing a key, drag mouse, etc.
Visual Basic combines the best features of object-oriented programming and
event driven programming.
THE OBJECT MODEL
Since Visual Basic uses features of object-oriented programming, we work
with objects in Visual Basic. We now define a few terms that are essential to
understand and used Visual Basic.
Object : An object is an entity or a thing. All the user interface elements such
as command button, text box, check button, option button, window, etc are
objects in Visual Basic. On your Windows desktop, the icons you see are objects.
i) An object is an entit5r or a thing.
i0 Objects can contain other objects. E.g., a form can contain buttons, text
box, label, menu, etc.
iii) Object consists of data and code to operate on that data.
iv) Objects have properties. These properties can be set when an object is
created, but we can also assign a new property later.
v) Examples of objects are form, command button, text box, check box,
option button, image box, etc.
Properties : All objects have properties.
0 A property tells us something about an object. Just as a book has
properties such as number of pages, length, breadth, type of cover,
edition, etc., similarly, all objects in Visual Basic have properties.
ii) We can refer to the property of an object by separating the object name
and property with a dot (.). For example, a command button may have a
caption and this can be written as cmdClear.Caption. Here, cmdClear is
the name of the object and Caption is its property.
iii) Objects have a default property which can be changed by the programmer
at design time or at run time.
iv) Properties can be set when an object is created, but we can also assign a
new property later
Methods : Methods are actions associated with objects. For example, Print,
Clear, Resize, Move. On a music system you may have the play, fast forward or
reverse buttons. Once any of these buttons is pressed, the system can perform
without any further assistance from us. These buttons perform some actions.
Events : An event is an action recognized by a form or a control. When
particular event takes place, the code for that event is executed. E.9., when a
command button is clicked, the code for the click event of that button is
I \
94 t't't' Compruter Sysfems andApplications-T.Y.B.Com.-(*m.W
executed. Each object in Visual Basic has a predefined set of events it can
respond to. Certain events occur along with other events. For example, when the
double click (DblClick) event occurs, the MouseDown, MouseUp, and Click events
also occur.
WRITING VISUAL BASIC PROJECTS
Writing a Visual Basic project is a three step process. These 3 steps are :
Step 1 : Design the User Interface (UI).
The user interface will decide how the program will look and how it will
process information. The complete set of screens and images used in a program
is called the program's user interface.It includes menus, command buttons, text
boxes, option buttons, etc.
In designing the user interface we first draw a rough sketch of the screens
the user will see. In this design we show the different objects, their position on
the form, and gives names to each object. We must discuss this aspect of the
project with the user.
Step 2 : Define the properties.
For each object, we must write down the properties that are to be changed
during the design of the form.
Step 3 : Creating the code (programs).
This step involves writing the code that will execute when the program runs.
We write code for each event that can take place.
VISUAL BASIC PROJECTS
Visual Basic projects consist of the following types of files :
O The .VBP file : This is called the project file. It is a small text file that
contains names of other files used in the project. It also contains some
information about the Visual Basic environment.
O The .FRM file : Each form in the Visual Basic project is saved with a .FRM
extension. This file contains description of all objects and their properties
for the form. It also contains code that we have written to respond to the
events. Each form file is called as a form module.
O The .BAS file : A file with extension .BAS contains code that can be
accessed from any form in the project. Such files are also called standard
code modules.
O The .OCX fi1e : Additional controls are also called custom eontrols, and
these are stored in files with extension .OCX. If you add controls in your
project that are not part of the standard control set, then the .OCX files
must be included in the project.
O The .VBW file : After we save a project, Visual Basic automatically adds a
file with extension .VBW. This file contains information about each form
in the project.
THE VB INTEGRATED DEVELOPMENT EITVIROITMENT (IDEI
Integrated Development Environment or IDE is a term commonly used in the
programming world to describe the interface and environment that we use to
create our applications. It is called integrated because we can access all the
development tools that we need from one screen called an interface. The IDE is
also commonly referred to as the design environment.
The Visual Basic environment enables us to create and test our projects. The
Visual Basic environment consists of the following components :
Basic
Introduction to Visual t jl jo gs
1. The Forn trIlndow or Form Designer : (Fig. S.1) This is where we design
the forms and plan the user interface. When we start a new project Visual Basic
automatically gives the default name Form I to this form. This name can be
changed later.
ldi.rosott Visual Easic Idesign]
t Frolc,:11 F(,nnl
= -rtX
{Fornr)
r Frrltr 1
Fig. 8.1
ie.tl
2. The ProJect Erplorer Window : (Fig. 8.21 This
window shows the filenames for the files included in the Preildf
Frymj
project. The name of the project with extension .VBP, is ,S@
shown in the title bar of this window.
FiS.8.2
3. The Propertles Wlndow : (Fig. 8.3) From this window we can set the
properties of the different objects, such as change ttre background color of the
form, change the size of a button, etc.
Propertaes - Fornrl EI
l-3D
2 - Sizable
Forml
True
True
13- Pen
D - Solid
True
&t-tooooooooS
M5 Sans Serif
True
rig.8.3
96 t't'l,' Computer Syslems and Applications - T.Y.B.Com.-(Sem. VI)
ser::g
tI PichfeBox
Label Arl
4. The ToolBox Window : (Fig. 8.4) The Toolbox Frme
command button, check box, text box, etc. These tools ListBox
t
can be plac'ed on the form by double-clicking on the t
respective icon.
Timer
!rl
The various controls shown in the above figure are JI
described below :
Shape
f,r.
knage
Data
OLE
rig.8.4
Control Description
Polnter Provides a way to move and resize the controls form
PictureBox Displays icons/bitmaps and metaliles. It displays text or acts as a
visual container for other controls,
TextBox Used to enter text and display message.
Frame Serves as a visual and functional container for controls
CommandButton Used to carr5r out the specified action when the user chooses it.
CheckBox Displays a True/False or Yes/No option
OptionButton OptionButton control which is a part of an option group allows
the user to select only one option even it displays mulitiple
choices.
LlstBox Displays a list of items from which a user can select one.
ComboBox Contains a TextBox and a ListBox. This allows the user to select
an ietm from the dropdown ListBox, or to type in a selection in
the TextBox.
HScrollBar and These controls allow the user to select a value within the specified
VScrollBar range ofvalues
Timer Executes the timer events at specified intervals of time
DriveLlstBox Displays the valid disk drives and allows the user to select one of
them.
Dirl,istBox Allows the user to select the directories and paths, which are
displayed.
FlleListBox Displays a set of files from which a user can select the desired
one
Shape Used to add shape (rectangle, square or circle) to a Form
Llne Used to draw straight line to the Form
Image used to display images such as icons, bitmaps and metaliles. But
less capability than the PictureBox
Data Enables the use to connect to an existing database and display
information from it.
OLE Used to link or embed an object, display and manipulate data
from other windows based applications.
Label Displays a text that the user cannot modiff or interact with
Introduction to Visual Basic gT
1. The Form Layout Window : The position of the form on the desktop can
be adjusted from this window.
2. Menu Bar : This Menu Bar displays the commands that are required to
build an application. The main menu items have sub menu items that can be
chosen when needed. The toolbars in the menu bar provide quick access to the
used commands.
DESIGN TIME, RUN TIME AND BREAK TIME
Visual Basic has three distinct modes :
a) Design Time
b) Run Time, and
c) Break Time
af Design Time : When we are designing the user interface and writing the
code, we are in design time. Any errors that occur in the IDE and before the
program is compiled are called design time errors. Syntax errors detected at this
stage.
bl Run Time : When we are testing and running our project, we are in the
run time mode. Certain errors can be detected only on running the program.
Such errors are called run time errors. For example, consider the statement
Result = A I B.This will give an error only when the value of B is zero.
cf Break Time : When we get an error in the run time or when we pause
execution of a we are in the break time.
FINDING AND FIXING ERRORS
Three t5rpes of errors are possible in a program. These are :
1. Compile Time Errors
Visual Basic must convert our source code (i.e., the program we write) to
machine code before the program can run. This is called the compilation phase.
During the compilation phase, if Visual Basic.finds any erors in the s5mtax, then
it is called compile time error. Examples of compile time errors are s5mtax errors,
not declaring a variable, illegal use of objects, using an object name that is not
declared. The word s5rntax means "grammar". Thus s5mtax errors are errors that
occur when we do not follow the rule of Visual Basic programmirrg. E.g., using
the word ENDD instead of END, a missing bracket, etc.
2. Run Tlme Errors
This is an error that causes a program to stop unexpectedly during
execution. Run time errors occur during execution. When such an error occurs,
Visual Basic displays a dialog box and goes into break time. The statement that
caused the error is highlighted.
Run time errors occur not due to the syntax but because a statement cannot
be executed, e.g., trying to open a non-existing file for reading, or division by
zero. Consider the example, where the user has to enter values of two variables A
and B and the program must divide A by B. If user enters value of A as 6 and B
as 2, the calculation RESULT = A/B will store the value 3 in variable RESULT.
But if the user enters the value of B as 0, then we get the run time error "Division
by zero".
3. Logic Errors
This is a human error. The program will execute but will gtve a wrong result.
For example, consider the problem of finding the average of 3 integers A, B and
C. If the programmer writes the statement AVG = A + B + C / 3 then this will
produce a wrong result but there will be no s5mtax and no run time error. The
correct way of writing this statement is of course AVG = (A + B + C )/3. Note the
brackets in this statement.
98 ,'t"r' Computer Sgstem,s and Applicatbns - T.Y.B.Com.-(Sem. VI)
Logrc errors cannot be detected by the compiler but must be tracked down by
the programmer. The output obtained must be viewed critically and the program
must be tested for all possible values of inputs to see that the output obtained is
meaningful.
GETTII{G STARTED WITH VISUAL BASIC
In Microsoft Windows XP, click the Start button, point to All Programs, and
point to Microsoft Visual Studio 6.0. Click on Microsoft Visual Basic 6.O.
Start -* All Programs --* Microsoft Visud Studio 6.0 -- Microsoft Visual
Basic 6.0
1. Visual Basic loads and we see the dialog box as shown in Fig. 8.5 :
New Projecl ? ><.
xo le**irsl nr6.l
kb
A(tlv.X EXE Acti%X oLL ActivrX \/8 Appken
Cmhol *&ed
N
VE Wiz{d
M!n4!r
g
ActiEX
Docmt Dll
g
Adivox
Documdt E!.
s
Addl
&
Ddr Pro,qt
l- s*' -l
cryd I
E"b I
lYew Box
This dialog box prompts us to s elect type programming project.
2. Select Standard EXE as shown in Fig. 8.5 and click Open button. A new
project opens in the Visual Basic programming environment.
3. The following window appears (Fig. 8.6).
^
proic.ll Mic.osorl visudl lldsi(: I dcriRDl n[x
Ba En yB Bo,d FsM Qlt { Bo qr.ry q.ors loob Ad&h ffi, tt b
& r.b ) ll o,0
@e
Flg.8.6
Basic
Introdudionta Visual t'jl'lr" 99
Although the screen can look confusing, we can fully customize the Visual
Basic screen to suit our needs and preferences. These windows are all
dockable; a dockable window is one that we can resize and move to the sides
of the screen and connect to other windows.
We will now develop a simple application to print the message "Hello World".
4. On the left side of the screen we can see the toolbox (if this doesn't show up
go to the top menu bar and select View -> Toolbox). In this toolbox you will
see a picture of a button. Double click the button icon and it udll create a
Commandl CommandButton in the center of your form. (Fig 8.7)
+ Projecll 'Microsoft Visual B*ic Idesign] -[Forml (Forml] trIEB
lil
r [orm1 rltElE
Proi€ct I
Form5
b Foml (Forfil)
..r i'
Ftg.8.7
5. We now place one more command button on the form. To do this, again
double-click on the Command Button icon in the tool box. The form now
looks as shown in Fig. 8.8.
\ Pro jecll I orml {, orm} l": trft rl
r I orml -:x
Cqmdl Cmrd2
Fig.8.8
6. Place a label object on the form. Double click on the label object in the tool
box. This creates a label object with the caption Label 1'
7. Now we set the properties of the label object.
a) Click on the label on the form. Click on the title bar of the Properties
window. The object box at the top of the properties window is showing
Label1 which is the default name of the object.
8/T.Y.B.Com - Com. Sys. & Appl. (Sem. - VI)
lOO t't't' Comprier Systems andApplications -T.Y.B.Com-(km. VI)
b) Select the Name property. Click on Name and notice that the Settings box
shows Labell as the default name of the label. 1}pe lblMsg so that this
becomes the new nzrme of the label object.
c) Click on the Caption property of the label. The Caption propert5r of a label
determines what will be displayed on the form. It shows "Label 1". Press
the Delete key so that caption disappears.
8. Now we set the properties of the command button 1 object.
a) Click on the first command button (Command Button 1) and then click on
the Properties window. It shows the properties of the Comamnd Button.
b) Change the name of the command button to cmdMsg.
c) Change the Caption to Message. The word "Message" (without the quotes
marks) will now appear on top of the first command button.
9. Now we set the properties of the command button 2 object.
a) Click on the second command button (Command Button 2) and then click
on the Properties window. It shows the properties of the Comamnd
Button.
b) Change the name of the command button to cmdExit.
c) Change the Caption to Exit. The word "Exit" (without the quotes marks)
will now appear on top of the first command button.
1O. We set the Caption properties of the Form.
a) Click on the Form and the Properties window will now show properties of
the form.
b) Change the Caption property of the form to "Hello World". The Caption
propert5r of the Form determines the text that will appear in the tifle bar
of the Form window.
The interface has now been designed and now we must write the code that
will be executed when the user clicks on the two command buttons.
11. Visual Basic code is written in Sub procedures. Each sub-procedure begins
with the words Private Sub and ends with the words End Sub. Event
procedures are automatically named by Visual Basic. The object name is
followed by the underscore character (_) and then the event name. E.g.,
cmdMsgCtck$.
12. Double click the command button named cmd Exit. This brings up the code
window as shown in Fig. 8.9 below :
t Projecl l I orml (Codc! X
Fig. 8.9
Introduction to Visual Basic t,'lt't' 101
Click in between the lines Private Sub cmtExif_Click0 and End Sub. Press
the Tab key once to indent the code (i.e. shift the code to the right). Then type
the following lines :
'End the program
End
The code will now look like this
Private Sub cmdExit_ClickQ
'End the program
End
End Sub
The statement that begins with the tharacter is called a comment statement.
It is ignored by the Visual Basic compiler but it tells the programmer the
purpose of the sub-procedure.
The statement End signifies the end of the program.
13. Now we write the code for the other command button i.e. cmdMsg. Double
click this command button to bring up the code window for cmdMsg. I}pe
the following code :
Private Sub cmdMsg_Clickfl
'Message t o display when this button is clicked
lblMsg.Caption = "Hello World"
End Sub
14. Now run the program by clicking on the Run menu, and choose Start. Or we
may also click on the Run button that appears on the tool bar (solid triangle).
15. On running the program we see the following window :
r Forml .
Mcsage Exl
Ftg.8.10
If we click on the Message button, the output appears as follows
r Forml
HdoWsH
Ex*
EESr-3
Ffg. 8.11
1O2 lr'tn ' Computer Systems and Applications - T.Y.B.Com-(*nt' W)
OBJECTIVE QUESTIONS
I. State whether the followlng are true or falsc :
1 Visual Basic is an event-driven programming language.
2 All programming languages are event driven languages.
3 Visual Basic can be used to develop GUI based applications.
4 Multiple events can take place at a time.
5 The Project Explorer window shows the properties of an object.
6 Various controls such as the TextBox, Label, CommandButton are found in the
Project Explorer window.
7. MouseDown is an example of an event in Visual Basic.
8. Move is an example of a method in Visual Basic.
9. The properties of different objects can be set from the ToolBox window.
to Visual Basic code is written in sub-procedures.
u. Multiple Choice Questlons
Select the most approprlate alternatlve from amoagst those glven and rewrlte
the sentence :
1. _ are the basic building blocks of Visual Basic Application.
a) Forms b) Method
c) Events d) Controls
2. Advantages ofVB are :
a) Rapid application development b) Event driven program concept
c) Create applications with GUI d) All of the above
3. The window that describes every individual element of a form is
a) Form window b) Property window
c) Project window d) None of the above
4. contains the controls, which one carr use in the creation of a form.
a) Menu b) Tool Box
c) Tool bar d) Project window
5. Which of the following file types contains the names of other files used in a Visual
Basic project?
a) .FRM; b) .OCx
c) .VBP d) .FRM
6. The only object-oriented language amongst the following is :
a) CoBoL; b) C
c) Visual Basic; d) C++
7. The only event-driven language amongst the following is :
a) C; b) C++;
c) 'Visual Basic; d) COBOL
Introductionto Visual Basb ,,,,'r, 1O3
8' If an object obj has,a property prop than which of the following is the best way to
state the property of the object?
a) obj; obj.prop; b)
c) prop.obj; prop d)
9. In a vB project, the form design is carried out in the window :
a) Properties; b) ToolBox;
c) Project Explorer; -
d) Form window
10. Which of these is not a distinct mode of Visual Basic?
a) Run Time b) Design Time;
c) Break Time d) Compile Time
11. Which of these errors can be detected at compilation stage by the Visual Basic
compiler?
a) Syntax error; b) Run time error;
c) Logical error; d) All ofthe above
12. Visual Basic code is written in _.
a) Sub procedures; b) functions;
c) Form; d) routines
13. The comment character in Visual Basic is :
a) tharacter; b) the /* */ character pair;
c) the / / character, d) the g character
14. Which of these is not a component of Visual Basic IDE?
a) Form Window; b) ToolBox;
c) Picture box; d) Project Explorer window
15. What is the meaning of VBP?
a) Visual Binary Project; b) Visual Basic Project;
c) Very Basic Project; d) Visual Basic Parameter
ANSWERS
I. [True : I,3,4,5, 7, 8, 10
False : 2, 6,91
III. [(l -a), (2-dl, (3-b), (4-b), (5-c), (6-d), (7 -c), (8-b), (9-d), (10-d), (11-a),
(12 - a), (13 - a), (14 - c), (15 - b)l
QUESTIONS
1. What programming language is Visual Basic based on?
2. What are procedural languages? Give two examples of such languages.
3. What are object-oriented languages? Give two examples of such languages.
4. What are event-driven languages? Give two examples of such languages.
5. What are the differences between procedural and event-driven programming
languages?
6. Why is Visual Basic known as event-driven programming language?
7, What is an object? Give some examples of objects in Visual Basic.
8. What is meant by the term "propert5/ of an object? Give some examples.
9. Differentiate between properties, methods and events.
10. In Visual Basic, what is design time, run time and break time?
11. What are the different types of errors that can occur in a Visual Basic program?
12. With the help of an example, explain the term "compile time error".
13. With the help of an example, explain the term "run time error".
14. With the help of an example, explain the term "logical error".
1O4 jl"jl"jl" Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
15. What are the different types of files in a Visual Basic project?
16. State the purpose of each of these Visual Basic file types: .VBP, .FRM, .BAS, .VBW
and.OCX
17. What are the three steps for planning and creating a Visual Basic project?
18. What are the components of Visual Basic IDE?
19. What is a Visual Basic event? Give some examples.
20. What is the purpose of remark or comment statements in a Visual Basic program?
22. Short Notes
Write short notes on the following :
1. Tlpes of programming languages.
2. Objects, properties, methods and events.
3. T}pes of files in a Visual Basic project.
4. Compile time errors.
5. Logical errors.
6. Run time errors.
,"t?'
Vriable s, Constants and C alculations t"t"'" 105
Yariables, Constonts
9 and Calculations
INTRODUCTION
Visual Basic programming language can be used to write programs which
involve many calculations. The most common arithmetic operations of addition,
subtraction, multiplication, and division are possible. In this chapter we will
study how data is stored and handled by Visual Basic.
VARIABLES
In programming, when we talk of a computer's memory, it usually means the
primary memory, i.e. the random access memory (RAM). Although the secondary
storage devices such as hard disk, pen-drive (USB drives), CD-ROM, etc are used
for storing data, from a programmer's viewpoint, RAM is more important. This is
because, all data must first be stored in the RAM, manipulated by the CPU, and
then it may be transferred to the secondary storage.
A computer contains vast amount of memory (RAM). Tlpically, this is abott2
gigabytes (approximately 2 billion locations) nowadays. Each memory location
has a fixed address. But since the number of memory cells is very large, it is not
possible for the progr€rmmer to keep track of these physical addresses. Also,
some memory locations will be used by the operating system such as Windows,
and so all the available memory of a computer is not for our own data.
A uariable is a memory location that lalds data tlnt can be changed during tle
execution of a program. TWo things are associated with a variable: its name and
data type. The variable name is used to refer to data stored in memory. The data
type decides what type of data can be stored in memory, what is the range of data
that can be stored (e.g. the largest and smallest number that can be stored), and
the permissible operations on that variable.
Declaring a variable : A variable must be declared before it is used. The
declaration of a variable means speciffing its data t5rpe. In Visual Basic, a
variable is declared as follows :
Syntax : Dim <varname, [AS <data typer]
o@@@
Thus, a declaration statement is made up of four parts which are as follows :
O DIM is a keyword. The word Dim stands for "dimension", which means
"size'. When we declare a variable, the amount of memory space required
depends on its data type. The memory requirements for various data
tSrpes are shown in Table 1.
@ <varna.me> is the name of the variable; the variable name is also called as
an identlfler as it identifies a memory location.
\
106 tn3'jl' : Conputer Sgstems and Applirations - T.Y.B.Com-(*m- VI)
VAL FUNCTION :
ARITHMETIC OPERATIONS
The arithmetic operations that can be performed in Visual Basic are listed in
Table 3 below:
Table 3 : Arithmetic Operations
Operator Operation Order of precedence
Exponentiation 1
I Division 2
Multiplication 2
+ Addition 3
Subtraction 3
Order of Operations :
The order in which the operations are carried out determines the result. This
order of operations is also called the trierarchy' of operations. The hierarchy of
arithmetic operators or order of precedence is shown in Table 3.
Example 1
Determine the value of the following expression : 3 + 5 ^ 2
Since exponentiation (^) has the highest precedence, this operation must be
carried out first. So we get : 5^2 = 25, and then we carry out the addition 3 + 25
to give the result 28.
Example 2
Determine the value of the following expression : (3 + 5) " 2
Note how the order of precedence has now changed as 3 and 5 are both
inside the bracket. Expressions inside the bracket must be evaluated first
(remember the BODMAS rule t). So we get 3 + 5 = 8, and then 8 ^ 2 gives the
result 64.
Convetting mathenatical erpressions into equivaleat Visud Baslc
statements:
There are implied mathematical operations in Visual Basic. For example, xy
is valid in mathematics and means x multiplied by y. But this must be written
x * y.
with the multiplication sign in Visual Basic, as follows:
Table 4 below shows a few mathematical equations/expressions and their
equivalent in Visual Basic.
t
110 t?"tt. - T.Y.B.Com.-(Sem'
Computer Systems and Applications VI)
Form Deslgn :
r [xchange Vdlues
lblBefore Befd6 ErchsrEF lblNum2
ged cmdExit
cmdExchange Exchalge
cmdClear
Note : We have set the Enabled property of Text boxes txtNum3 and txtNum4 to
'False' so that user cannot type anything in these text boxes. Values of these text
boxes are generated by our progr€rm
Event Procedures :
Sub cmdExit-Cltck(f
End
End Sub
114 t t computer $ystems andApplications-T.Y.B.com.-(Sem. VI)
lblMI<s2
u.tMks2
lblMks3 bcMks3
tsrtAvg
lblAvg
cmdAvg cmdExit
cmdClear
Event Procedures :
ProJect Code :
Prlvate Sub cmdAvgClick(f
Dim A, B, C As Integer
Dim avg As Single
A = Val(txtMksl.Text)
B = Val(txtMks2.Text)
C = Val(txtMks3.Text)
avg=(A+B+C) /3
b<tAvg.Text = FormatNumber(avg, 2)
End Sub
txtMks l.SetFocus
End Sub
lblRate b(tRate
lrterest Rde
lbllntAmt
lr*€rest Adpur* bclntAmt
lblTotal
TdalAmount b<tTotal
cmdCalculate cmdExit
Cdculate I C!ear Exit
I
cmdClear
Event Procedures :
Event Procedure Actions - Pseudocode
cmdCalculate_Click0 o Dimension the variables
a Convert text box values to numeric
o Calculate the simple interest by using the formula
I = PRT/100, and Total amount due = P + I
o Display the new values in the text boxes for interest and
amount.
cmdClear_Click0 o Clear the text boxes by setting their Tqrt propert5r to ""
(blank)
o Set focus back to first text box
cmdExit_Click0 End the program
ProJect Code :
Private Sub cmdCdc-Click(f
Dim P, I, R, T, Total As Single
I=P*R*T / IOO
txtlntAmt.Text = FormatCurrency(I, 2)
txtTotal.Text = FormatCurrency(P + I, 2)
End Sub
Private Sub cndClear-Cllct(f
txtPrn.Text = ""
txtYrs.Text = ""
txtRate.Text = ""
txtlntAmt.Text = uu
txtTotal.Text = ""
txtPrn.SetFocus
End Sub
OBJECTIVE
I. State whether the followirg are tnre or false :
1. All variables must be compulsorily declared in a Visual Basic program.
2. A declaration statement begins with the keyword Dim.
3. More than one variable can be declared in a single declaration statement.
4. The declaration statement is an executable statement.
5. The name given to a variable is also called an identifier.
6. The type of data must be specilied in a declaration statement.
7. The Single data type is used to store words or phrases.
8. The Date data type occupies 10 bytes of memory.
9. The Integer data t5pe occupies one byte for each digit in the number. E.g., the
number 367 will require 3 bytes.
10. The variant data type is the most efficient of all data types.
1 1. The output of Val(3 + 7) is 3
c) =NOT d) NoT=
5. '^' is the operator for performing the arithmetic operation.
a) Addition b) Multiplication
c) Subtraction d) Exponentiation
6. enforces the variable declaration before they are used.
a) Option Explicit b) Option Implicit
c) REM d) None ofthe above
7. which of the following statements is most appropriate for a variable :
a) It is a memory location that holds data that can be changed during the execution
of a program.
b) A name and a data type is associated with every variable.
c) Declaring a variable means specitring its data type.
d) A11 ofthe above.
8. Which of the following is appropriate variable name to store the marks obtained by a
student?
a) intMks b) 3MarksAccts
c) Marks+Accts d) M
Vriables, Constnnts and Catculations t't r' 11g
9. Which of the following statements is the correct way to declare a constant TAXRATE
that stores the value O.3O?
a) Const TAXRATE As Single = O.3O
b) Const TAXRATE As Single O.3O
c) Const TAXRATE = 0.30
d) TAXRATE = O.3O
10. The data t5rpe of a variable decides :
a) The range ofvalues that can be stored
b) The operations that can be carried out on that variable
c) The amount of memory that will be allocated to that variable
d) All of the above
I 1. Which of these is a disadvantage of variant data type?
a) We can store any type of data in a variant type variable.
b) It occupies the least amount of memory.
c) They operate less slowly than other data types.
d) Variant type variables need not be declared before use.
12. Which of the following named formats will return the day of the week, month and
year ofa given date?
a) vbGeneralDate b) vblongDate,
c) vbSortDate d) vbFullDate
ANSWERS
I. [True : 2, 3, 5,6, 8, 13
Fdse z l, 4,7,9, lO, ll, 1.2, 141
U. [(1-b), (2-a), (3-d), (4-b), (5-d), (6-a), (7-d), (8-a), (9-a), (10-d), (11-c),
(12 - b)l
QUESTTONS
1. What is a variable?
2. What are the rules for forming identifier narnes for variables?
3. Which of the following identifiers are valid as per the naming convention in Visual
Basic?
(a) strGrade, (b) curMRP, (c) Discount, (d) int.Marks, (e) sng@Amount, (0 Private,
(g) Form, (h) blnPassed, (i) 23intRank, fi) lng-Population
4. What are constants? What is the advantage of declaring a value as a constant?
5. State the types of constants used in Visual Basic. Give one example of each.
6. Write a declaration for the following situations; create an appropriate variable
identifier.
a) Integer number of days attended college
b) Single-precision number of hours
c) Mobile Telephone number (not used in calculations)
d) String address ofa person
e) PINCODE of the area in which your college is situated
7. What is the purpose of the VaI function?
8. State the mathematical operations in Visual Basic.
9. Explain the order of precedence of operators for calculations. How can this order be
changed?
lO. State the value of each of the following expressions :
a) 3*2+7*8
b) 1614.^2+8
c) 6 +3*8/(2+61
\
120 r?'I' Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
PRACTICAL EXERCISES
l. Create a project that determines the future value of an investment. The time period,
principal amount and interest rate will be input by the user. Display the future value
in a label, formatted as currency.
2. Write a complete progrurm that displays the message "l love Visual Basic" in the
caption of the label lblOutput when the user clicks the command button cmdClick.
3. Write a project in VB to design a suitable form to add two numbers and display their
sum.
,'t't'
D e cisio ns and Co nditio ns *'n?' 121
INTRODUCTION
A computer program must be able to take a decision based on certain
conditions and then execute statements based on the outcome of that condition;
if the condition is true, execute one set of statements, otherwise execute another
set of statements. This ability to take a decision is implemented in Visual Basic
through many decision making statements and conditions.
Control Structures :
a) If...Then statement
b) If...Then... Else statement
c) If ... Then...Elseif statement
d) Select... Case statement
ii) Loop structures such as:
a) Do...While loop
b) While...Wend
c) For... Next loop
In this chapter we shall explore the If...Then statements and their use in
programs. But before that we study about the relational operators in Visual Basic
as these are required to form the decision statements such as If... Then and its
variations.
Relational Operators
A relational operator gives a relation between its operands. E.g., when we
write 2 . 3, t]ne operands are 2 arrd 3; the relational operator is the less than'
sign (<). The expression 2 < 3 is called a relational expression and it can give only
two possible results: True or False. Thus, whenever a relational operator is used
the result of the expression is either True or False.
The following table summarizes the six relational operators used in Visua1
Basic.
122 t't"t" Computer Sgstems and Applicatians - T.Y.B.Com-(Sem. VI)
Else
Max=B
End if Ftg. 1O.2
Decisions and Condition s ft"C 123
Erample 2 :
Ifaverage >= Then
5O
txtResult.Text ='Pass"
Else
brtResult.Text = "Fail'
End if
THE NESTED IF ...THEN ... ELSIE STATEMEITT :
A
&\
124 t"r't" Com4ruter Sgstems and Applications -T.Y.B.Com.-(Sem. VI)
T T
l T
4 -3 -2 -1 o 1 2 3 4
Examples
1. Write the statements necessary to compare txtNuml.Text and txtNum2.Text.
Display in lblMax.Caption, which has more value.
Ans. : If txtNuml.Text > txtNum2.Text Then
lblMax.Caption "Num1 is greater than Num2"
Else
lblMax.Caption "Num2 is greater than Num1"
End If
2. Write statements that allow the user to type an integer in a text box. Print
the number of digits in the number. Assume that the number entered is
between 1 and 1000.
Ans:
N = Vaf(txtNumber.Text)
IfN<10Then
digits = 1
Elself number < 100 Then
digits = 2
Else
digits = 3
End If
lblDigits.value = digits
ASCII Code :
ASCII is the abbreviation for American Standard Code for Information
Interchange. Every character has a unique numeric code associated with it. For
example, the character 'A'has the ASCII code 65, B, has the ASCII code has 66,
etc. The following table gives the ASCII codes for alphabets and digits :
ASCII Code Range Character Raage
48-57 Digits O - 9
65-90 Letters A - Z
97 - L22 Letters a - z
Thus:
a) All numeric digits are less than all letters.
b) Since the ASCII code of A is less than that of B, A < B.
c) Uppercase letters are less than lowercase letters.
Decisions and. Cortditiorc ,ntnjln 125
Comparing Strings
Comparison of string variables begins with the left-most character and
procieds one character at a time from left to right. As soon as the character in
one string is not equal to the corresponding character in the second string, the
comparison ends. The string which has a character with smaller ASCII code is
said to be smaller than the other string.
Eramples:
1. comparison of "RAM" and "RoM". RAM is less than RoM as A has the
smaller ASCII code of 65.
2. Comparison of 203PDR with PDR. If the digit 2 is compared with the letter P,
2 is lower since all numbers have lower ASCII codes.
Comparing Text Propett5r of Tert Boxes :
Visual Basic compares one text box to another as strings. We can carry out a
numeric comparison on Text property by using the Val function. The following
table shows a few examples of comparing numbers in text boxes.
txtNuml.Text txtNum2.Text txtNuml.Text Val(txtNuml.Text)
txtNum2.Text Val(txtNum2.Text)
1 +1 True False
ASCII code of 1 is Val of both text boxes is
greater than the ASCII the same, so they are
code of the + sign equal.
0 (blank) True False
ASCII value of 0 is Val converts blank to 0,
greater than that of so both are equal.
space (blank)
placed in the clickfl event of the command button. This If statement can check
which options were selected.
Here is a simple progrErm that checks the value of an option button.
Eranple I : To Test the Value of an Optlon Button
Create a project that contains three option buttons labeled "Commerce",
oArts", "Sciencl", a label, and two command buttons with captions "Show" and
"Exit". The user selects one of the options and on clicking the Show command
button, the r-nessage "You selected ----- facult5f should be displayed as the
caption of the label- The dash (-----) is replaced by the option selected. E.g., "You
selected Commerce facult5/.
Form Deslgn :
r Oplion Sullon lf Stmt f:ttE It
fraFaculty
optCom
optArts
Sc*re
optSc
lblFaculty
rE. 1O.3
Objects and thelr Propettles :
ObJect Property Value
Form Name frmlnterest
Caption Option Button-If Stmt
Frame Name fraFaculty
Caption Faculty
Option Button Name optCom
Option Button Name optArts
Option Button Name optSc
Label Name lblFaculty
Caption "" (blank)
Command Button Name cmdShow
Caption S&how
Command Button Name cmdExit
Caption &Exit
Event Procedures :
Icon Message
Thisb an exa$b d a
'- a-
Buttorr Csrcel
Ftg. 1O.4
To display the buttons, we can use the following intrinsic constants of Visual
Basic.
Constant Vdue Button(sf displayed
vbOKOnly 0 OK button
vbOKCancel 1 OK and Cancel buttons
vbAbortRetryIgnore 2 Abort, Retry, and Ignore buttons
vbYesNoCancel 3 Yes, No, and Cancel buttons
vbYesNo 4 Yes and No buttons
vbRetryCancel 5 Retry and Cancel buttons.
vbCrtical 16 Critical Message Icon E
vbQuestion 32 Question mark
g
vbExclamation 48 Warning Message icon tr
vblnformation 64 Information message icon e
If the title bar caption is omitted, it will display the project name in the
message box title bar.
A message box can be used to display a message when the user has entered
invalid input.
Example :
If txtMarks.Text = "" Then
MsgBox "Please enter marks". vbOkOnly, "Marks Not Entered"
Endif
Input Validation
Input validation means checking whether the data input by the user is
correct or not. Validation may include checking for the following :
i) check that data is numeric
ii) check that data is in a particular r€rnge
iii) check that a field has not been left blank
Checking for Numeric Values wlth the IsNumeric function :
The IsNumericfl function of Visual Basic checks whether its argument is
numeric or not. This function returns the value True if its argument is numeric,
else it returns False. This function can be used to check whether the data can be
converted to a number for calculations, otherwise an error message can be
displayed.
Syntax:
IsNumeric (expression)
Decisions and Conditions t"rnto 12g
Erample:
If IsNumeric(txtMarks.Text) Then
Mks = Val(txtMarks.Text)
Else
MsgBox "Nonnumeric data entered", vbokonly, "Invalid Data"
End If
Checklng for a rangc of values :
Data validation may inclucie cheeLi.rs, t}at data cntered is within a certain
range - e.9., marks are between 0 and 10O.
Example:
Mks = Val(txtMarks.Text)
If Mks >= 0 And Mks <= l0O Then
Total=Total+Mks
Else
MsgBox "Marks must be in the range 0 - 10o", vbokonly, "Invalid Data"
End If
Checkiag for a Requlred Field (Field not left blankf :
If we want to ensure that a text box has not been left blank, we can compare
the text box value to an empty string.
Erample:
If txtMarks.Text = "" Then
MsgBox "Please enter a value", vbOkOnly, "Blank Field"
Else
Total = Total + Val(txtMarks.Text)
End If
PROGRAMMING EXRCISES
1. Maximum of three integers
Create a project that computes the maximum of three integers entered by the
user. Display the result in a message box.
Form Design :
i Ldrgesl of 3 Nos l; lln ilt I
ffi
lt
I
I
I
I
I
I
FindMu I
I *. l_E* |
Flg. lO.5
Event Procedures :
Event Procedure Actlons - Pscudocode
cmdMax-Click0 Compares the numbers and finds their maximum. Displays result
lna box.
cmdClear_Click0 Clears the text boxes and positions the cursor in the first text box.
cmdExit-Click0 End the program
130 3l"t''. Compfier Systems and Applications - T.Y.B.Com.-(Sem. VI)
ProJect Code :
Hvate Sub emdMax-Cltck(l
Dim A, B, C, Max As Integer
A = Val(b<tNuml.Text)
B = Val(txtNum2.Text)
C = Val(b<tNumS.Text)
'first find the larger of A and B
lfA>=BThen
Max=A
Else
Man=B
End If
txtNuml.SetFocus
End Sub
r Folnrl EtrIIA
Nur&ar
l:l:
et^Eck
l: Ch" l: Ed
Ftg. 10.6
Deci.sbn s and Condilions t,'t't" 131
ProJect Code :
N = Va1(txtNum.Text)
r Fr:rtn1
Eh€ck CIear
Ftg. lO.7
ProJect Code :
Hvate Sub crndCheck-Cltck(l
Dim N As Integer
N = Val(txtNum.Text)
If N > 0 Then
MsgBox "Number entered is positivb (greater than O)", vbOKOnly
ElselfN<OThen
MsgBox "Number entered is negative (less than 0)", vbOKOnly
Else
MsgBox "Number entered is 0", vbOKOnly
End If
End Sub
OBJECTWE QUESTIONS
I. State whether the following are true or false :
1. The purpose of control statements is to control the flow of execution in a program.
2. Relational operators can be used between operands of same data type only.
3. Whenever a relational operator is used, the result of operation is either O or 1.
4. If statement cannot be nested inside another If statement.
5. Comparison of strings is done by using the ASCII code.
n. Multlple Cholce Questions
Select the most appropriate alternative from amongst those glven and rewrlte
the sentence :
1. Which of the following statements is most appropriate for relational operators :
a) They can only be used to compare operands of the same data t5pe.
b) They can be used to compare only numeric data types such as integer and string.
c) They can be used to compare only string data gqpes.
d) The relational operator for "not equal to" is !=
2. The ASCII code of alphabets is _ than that of digits O to 9.
a) Less than
b) Greater than
c) Depends on whether it is lower case or upper case alphabet
d) Cannot be said with certainty
Decisions and Conditions t.t"3;" 133
3. What is the purpose of the if...then statement?
a) To execute a set of statements
b) To check a condition, and if it is false, execute a set of statements
c) To check a condition, and if it is true, execute a set of statements
d) To check a condition and if it is true, execute one set of statements otherwise
execute another set of statements.
4. What is the purpose of the if...then...else statement?
a) To execute a set of statements
b) To check a condition, and if it is false, execute a set of statements
c) To check a condition, and if it is true, execute a set of statements
d) To check a condition and if it is true, execute one set of statements otherwise
execute another set of statements.
lANswEREl
I. True : 1,2,5
Fdce:3,4
III. [(1 - a), (2 -bl, (3 - c), (4 - d)]
lauEstrousl
1. State the relational operators in Visual Basic.
2. What are logical operators? Explain their purpose in Visual Basic.
3. Explain, with a suitable example, the If..Then statement in Visual Basic.
4. Explain, with a suitable example, the lf..Then...Else statement in Visual Basic
5. What is the nested If...Then statement? Explain with an example.
6. Explain, with a suitable example, how Visual Basic compares numeric data.
7. Explain, with a suitable example, how Visual Basic compares string data.
8. What is the ASCII code?
9. What is a message box? When is it useful?
10. Give an example of three message box constants.
1 1. What are the components of a message box?
12. What is mea:rt by the term "validation"?
13. What are the different types of validation?
14. Explain each of the following validations, with an example:
a) Range checking
b) Check for numeric data
c) Check that a field has not been left blank
PRACTICAL EXERCISES
1. a) Suppose the variable paA has been assigned the value of 6.50. Test the value of
variable laurs. If hours exceed 40, assign the value of 9.75 to pag.
b) Test the value of variable hours. If hours is less than or equal to 40, assign 6.O0
to pay and assign "Regular" to string variable status. If pay exceeds 40, assign
9.75 to pay and assign "Overtime" to status.
2. Suppose the variable age has been declared as an integer variable. Test the value of
age and if it is 18 or more, display the message "You are old enough to marr5/ in a
message box.
3. Suppose the variable age and gender are declared as integer and character type
respectively. Take the input from the user and declare the person as eligible for
marriage based on the following conditions: If gender is female and age is 18 years or
134 t't"t' Computer Sgstem.s and Applications - T.Y.B.Com--(Sem. VI)
more, the person is eligible to marry. If gender is male and age is 21 years or more,
person is eligible to marry. In all other cases, person cannot marry.
4. Ask the user to enter the marks obtained in an exam from 0 to 1OO. Display the
grade it represents - First class (60 or more), second class (45 - 59) and pass class
(40-441. Grade is Fail if mark is below 40.
5. Ask a salesperson to input the total value of sales. this year. If it exceeds { 1 lakh, the
bonus is t 10,000. If it is from { 70,000 to T 99,999, bonus is { 7,OOO and if it is Rs
5O,OOO to t 69,999 the bonus is ( 4,000. Sales less than t 50,000 receive no bonus.
6. Create a Visual Basic Project that will allow the user to enter a positive number and
determine whether it is odd or even.
t"t't"
Introduction to Visual Basic Controls
t't"t' 135
ll fntuoduction to
Yisuol Bosic Controls
INTRODUCTION
Visual Basic is a programming language through which we can create
programs with a graphical user interface. All the Microsoft Office products such
as Microsoft word, Excel, PowerPoint, etc. that we use have a graphical user
interface.
Programs with graphical user interface are made up of components like text
box, command button, label, check box, list box, combo box, frame, option
button, line, shape, image, etc. These components are called the GUI
components. Visual Basic also contains these components to be used in our
programs. Each of these objects has properties, methods, and events.
Controlr are used to get user input and to display output. E.g., text box,
label, check box, list box, combo box, are all controls.
Propertles of an object are the characteristics used to describe the object.
They tell us something about an object such as its name, size, color, location on
the screen. Certain properties can be changed at design time but others can only
be modified at run time. All controls have certain default properties.
Methodc are code executed by the program. E.g., Addltem and Removeltem
are methods associated with a list box.
Events : An event. is an action recognized by a form or a control. When a
particular event takes place, the code for that event is executed. Examples are
clicking the mouse, pressing a key, etc.
o Events need not necessarily be triggered by the user. They may be
triggered by other events also.
o The components of Visual Basic have built-in code that helps them to
recognize events.
o An interface component can recognize more than one event.
a The progrEunmer determines the response of a component to a particular
event by writing the necessary code.
o The component can be programmed to respond to more than one event.
OBJECT NAMING CONVENTIONS
its Name property to a
When we first create an object, Visual Basic sets
default value. E.g., command buttons are given the names Commandl,
Commnd2, Command3, etc. We must change the names of objects to more
meaningful and descriptive names.
136 t't"t" Computer Systems and Applications - T'Y'B'Com-(Sem' VI)
Caption
tr Calculator
EEE
+* Form
The following figure (Fig. 11.2) illustrates the various controls that can be
used in a Visual Basic project :
Text Box
F Calculator Ix
0.
Option
Button Oocc Oo.* Osir Oo"g* OF.ddrc
CE c
Sla MC 7 I s
MS 1 2 3 Lsh Nd
M+ 0 + lnt
D E F
rE. 11.2
THE COMMAND BUTTON
The command button is used to initiate an action. E.g., if the user clicks on a
command button, it may trigger an event that prints the contents of the screen,
or closes a program.
Namlng Conventlon : Command button names must start with the prefix
cmd e.g., cmdPrint
Command Button Propetties :
Property Dercrlptlon
BackColor Sets the colour of the Command Button's background. Style
property must be set to 1 - Graphical.
Cancel If this property is set to True, pressing the Escape key at runtime
will activate the Command Button's Click event. Only one
Command Button on the Form can have this property set to True.
Caption It is the text displayed on the command button
Default If this property is set to True, pressing the Enter key at runtime
will activate the Command Button's Click event. Only one
Command Button on the Form can have this property set to Trre.
The command button which has this property set to True will
appear with a darker border.
Name This property is used to give a name to a command button.
Tablndex Sets the order in which the controls will get focus when the tab
key is pressed. The control that has O as its Tablndex will have
focus when the Form is loaded.
ToolTipText When this property is set, the text will popup over the Command
Button when the user hovers the mouse pointer over it. This can
be useful if you cannot fit all the text you need to in the Caption or
to give helpful messages. to the user.
Introduction ta lfistal Basb Confrpls t"t?' 139
Command Button Mcthodr :
Method Dercrlptloa
Move This method changes the position of the command button during
program execution.
SetFocus Sets the focus to the command button. This means ttrat pressing
the Enter key will activate the Click event, even' if another
command button has it's Default propert5r set to True.
Command Buttoa Eventc:
Eveat Dcrcrlptloa
Click It occurs when the user clicks on the command button.
GotFocus Occurs when the command button gets focus either from the Tab
key, when it is clicked on by the user or by using the SetFocus
method.
LostFocus It occurs when the command button loses focus.
TEXT BOX
The text box is used to accept information from the user. It is also sometimes
called tJ:e input box.
ISamlag Coavcqtlon : text box names must start with the prefix brt.
E.g. trrtAuthor.
Tcrt Bor Propcttlcr :
Propctt5r Dcrcrlptlon
Alignment Used to change the alignment of text within the text box. The
values can only be set at design time and not at run time. These
values are :
0 - L€ft Justiff
I - Right Justiff
2 - Center
Enabled Value must be True or False. [f set to False, user cannot enter
data into this text box, but data can be displayed through a
program
Maxlength Determines the maximum number of characters that can be
entered in the text box. By default there is no limit on the number
of characters that can be entered in a text box.
Multiline Determines whether the text box can accept multiple lines of text.
Value can be true or false. By default, a text box accepts only a
single line of text.
Name This property is used to grve a narne to the text box.
Text This property is used to read or set the text in the text box.
(Default Property)
\
140 Computer Sgstems and Applications - T.Y.B.Com'-(Sem' VI)
Event Descrlption
Change Occurs every time the contents of the text box are changed
Click Occurs when the user clicks inside the text box.
GotFocus Occurs when the text box receives focus.
l,ostFocus Occurs when the text box loses focus
KeyDown Occurs when a key is pressed while the focus is in a text box.
KeyUp Occurs when a key is released while the focus is in a text box.
THE LABEL
The label object is used to place text on the form. It can be used to identiff
controls that do not have a caption. E.g., label can be placed next to a text box
to indicate the data that must be entered " by the user. The label cannot be
changed directly by the user at run time. lts contents can be changed through
the program or at design time.
Naming Convention : Label names must start with the prefix lbl. E.g.
lblAuthor.
Label Propertles :
Property Descriptlon
Caption This property holds the text to be displayed on the label. This can
(Default Property) be changed at design time or when a program runs.
FontBold Used to display text in bold font
Fontltalic Used to display text in bold font
Name This property is used to give a name to the label.
WordWrap If set to True, the text in the caption will display in multiple lines
Label Methods :
Method Descriptlon
Move Used to move the label at run time.
Label Events :
Events Descrlptloa
Click Occurs when the user clicks with a mouse on the label.
Change Occurs when the text of the label is changed by the application
Double Click Occurs when the user double clicks with a mouse on the label.
Event Descrlption
Click Occurs when the user clicks on the check box.
OPTION BUTTON
This control is called a radio button. It is used when the user can select only
one out of many options.
All related option buttons must be placed inside a frame and not on the form.
A group of option buttons placed inside a frame function together. To place
option buttons inside a frame, we first place the frame object on the form. Then
we click on the option button tool in the toolbox, and draw the option button
inside the frame. We should not double click the option button tool in the tool
box as it will only place the option button on the form and then even dragging it
into the frame will not make it a member of the group.
Naming Coavention ; Option button names must start with the prefix opt.
E.g., optRed.
Option Button Property :
Property Descrlption
Caption It is the text that appears next to the option button.
Value This property specifies whether the option button is selected
(Default Property)
Option Button Events :
Events Descrlption
Click This occurs when the user clicks inside an option button.
Thus, the difference between a check box and an option button is that in a
group of check boxes, any number of check boxes can be selected, but in a group
of option buttons, only one option button can be selected.
IMAGE CONTROL
This control holds a picture. We must set the Picture's property to an image
file with extension .JPG, .BMP, .GIF, .CUR, or .WMF
We first place the image control on the form, and then select its Picture
property in the Properties window.
Naming Conventlon : Image control names must start with tl' e prefix img.
E.g., imgPhoto.
\
142 t"t't' Computer Sgstems and Applications - T.Y.B.Com.-(Sem. V0
Image Properties :
Property Description
Picture It specifies the frle name of the picture that is to be displayed-
(Default Property)
Stretch This propert5r specifies whether a picture is to be resized to Iit the
size of the image control
Image Events :
Event Descrlptlon
Click This occurs when the user clicks inside an image control.
Ftg. 11.3
Introducrtionto Vtsual Basic Controls Ce'f 145
lblCustomer.CaPtion = ""
txtOrder.SetFocus
146 aPr.jP Comptter Systerzs andAppliutions-T,Y.B.Cont--(Sem. VI)
OBJECTIVE
I. State whether the following ere true or fdse :
1. Visual Basic projects can have more than one form.
2. Visual Basic provides ready-to-use interface components.
3. All controls have a Caption property.
4. The text box control is used only to display text.
5. There can be only one component of each type in a form. For example, only one
command button in a form.
6. On a form, more than one command button can have its Default property set to
True.
7. On a form, only one command button can have its Cancel property set to True.
8. Events can be triggered only by the user.
9. Properties decide the behaviour of a component.
10. Events and methods are the same thing.
I l. An object name can start with the underscore (-) character.
12. An object name can start with a digit.
13. Object narnes can be of maximum 4O characters.
14. Space character is not permitted in object names.
15. All properties of a component can be set at run time.
16. Once you have initially placed a command button on a form, you cannot reposition it
in any way even during Design time.
17. A check box can have three values of the Value property.
18. An option button can have more than two values of the Value property.
t
148 t'3l't' Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
19. The TAB key will stop at a control only if the control's TabStop property is set to
True.
20. SetFocus is considered to be an event.
U. Multiple Choice Questions
Select the most appropriate dternative from amongst those glven and rewrlte
the sentence :
1. Advantages of Visual Basic are :
a) Event driven programming concept
b) Rapid Application Development
c) Create applications with GUI
d) A1l ofthe above.
2. An action that an object is capable of performing is called as :
a) Event b) Property
c) Method d) None of the above
3. contains the controls which one can use in the creation of a form.
a) Menu b) Tool Bar
c) Tool Box d) Project Window
4. Which of the following is a valid object narne for a text box?
a) txtClass b) txt Class
c) txt+Class d) All of the above
5. Which of the following statement is incorrect in naming a variable in Visual Basic?
a) Must begin with an Alphabet
b) Must not exceed 255 characters
d) Must have an embedded period or a special Character
e) Must be unique within the same scope.
6. IDE is _:
a) A development environment for machine language
b) Integrated Development Environment for Visual Basic
c) A software project management tool.
d) Independent Debugging and Encoding tool.
7. Which of the following is a part of the Visual Basic IDE?
a) Code window b) Properties window
c) Project Explorer d) All of the above
8. The application name always appears in the _ window:
a) Project explorer b) Intermediate window
c) Title bar d) properties window
9. The color of a cbmmand button
a) Is not changeable
b) Defined in the project
c) Can be changed at runtime
d) Can be changed in the Intermediate window
10. In the IDE, which of following is used to design the layout of an application?
a) Form Designer window b) Froject Explorer wind.ow
c) Context Menu d) Form Layout wind.ow
1 1. The location of the form on the desktop during execution is determined by the:
!
Introduction to Visual Basic Controls t,r't, 14g
c)
Use the Project Menu to select Run
d)
None ofthe above
14. The reference library of Visual Basic books is called:
a) MSDN Library b) Help Library
c) Contents d) Topic pane
15. Tool bar:
a) Is part ofthe tool box
b) [rpically appears at the bottom of the screen
c) Contains relevant icons
d) Is part of the Menu
16. Double clicking on the command button icon in the tool box will :
a) Do nothing b) Highlight it
c)
Move it to the form d) Place it on the form
17. The first step in building a project is :
4. State the purpose of the following components in Visual Basic: Form, Text box,
Command button, label, check box and option button.
5. What are the object naming conventions in Visual Basic?
6. State the naming convention for the following components in a Visual Basic project :
form, shape control, image, line, text box, command button.
7. State and describe at least one propert5r of each of the following controls: form, text
box, command button, label, line, shape control, option button, and check box.
8. State and describe one method of each of the following controls: form, text box,
command button, label.
9. State and describe one event associated with each of the following controls: form,
text box, command button, label.
10. What is the difference between a text box and a label?
11. What is the purpose of the check box control? Explain with an example.
12. What is the purpose of the option button? Explain with an example.
13. What is shape control used for? State any two properties of the shape control.
1.4. What is the image control used for? What is its dbfault property?
15. How does the behaviour of option buttons differ from those of check boxes? OR What
is the difference between option button and check box.
16. State the default property of the following controls: text box, label, shape, check box,
and option button.
17. What are keyboard access keys? What is the purpose of access keys? How can you
deline them in your project?
18. What precautions must be taken by the programmer while defining access keys?
19. Explain the Default property of a command button.
20. Explain the Cancel property of a command button.
21. Explain TabStop and Tablndex properties of a control with the help of an example.
22. What is the focus? How can you change which object has the focus?
23. How are the With and the End With statements used? Explain witJ: an example.
24. What is a ToolTip? How is it created?
25. What is concatenation? Give one example.
26. What are the principles of designing a good user interface?
r??"
Aduanced Features of Visual Basic l,'l,'t' 151
Adoanced Feotures of
Yisual Basic
nkr6oft 6,0 Y
)
Common
Dialog Control
CsEd
Open
iTllEl
{- e}
&
My Berent
Documer*s
Documents
my Computer
Network Places
Adobe Reader I
Toolbox.l.9
Free Movies & Games
?
iTunes
Nero Startsmart
Nok6 Music
QukkTime Phyer
RealPlayer 5P
samrung PC studio 3
File name:
Ftes of type:
r
DlS. 12.2: Flle Opea Dlalog Bor
2. Select a file form the list shown in this box and click on OK. The filename is
displayed on the form.
Color Dialog Box :
The Color dialog box allows the user to select a color from a palette or to
create and select a custom color. At run time, when the user chooses a color and
closes the dialog box, the Color property is used to get the selected color.
Erample 1:
On a form, place a common dialog control. In the Properties window, change
its name to dlgCommon.
We can now use this dialog to display the Color dialog l FItx (-alo
box as follows :
0 Create a command button and set its caption as ITTT TT r
Color.
ii) Name the command button as cmdColor.
iii) In the Click event of this button, type the following
code :
Private Sub cmdColor-Click$
'Display the Color box
dlgCommon.ShowColor
Cmd OK
End Sub
Run, the program. On clicking the command button,
the following color selection window appears (Fig. 12.3) : -.----- -
"T.;l1i;i1':l
Font Dialog Box :
The Font dialog box allows the user to select a font by its size, color, and
style. Once the selection has been made in the Font dialog box, we can use the
properties of the Font dialog box, to set the font.
154 tt't?' Computer Systems andApplications-T'Y'B'Com-(Sem' W
Bold
Bold ltalic
Status: i*e**ai&
lrne: l.FLa$.d.. Su*rarll
ryr
I LEKI:
rr::rri
8K'1
ts
AddRtlt.r
&&
hgtBr* iM,Os
l0t0sr... oGrslt...
Prffi
R.o*" '
l-cCirr
Co.rwt
I. Event procedure
a Event procedures
a Sub procedures
o Function procedure, and
o Property procedure
Event procedure is the c'ode that is exccuted in response to events such as
mouse click, key press, change in an object's state, dragging the mouse, etc. So
f,ar we have used only' event procedures. Non-event procedures i.e., sub-
procedure, function procedure and property procedure are not event-dependent.
These three procedures are called. from an event prccedure or from another non-
event procedure. We shall shrdy in detail about sub-procedures and function
procedures as the more advanced topic of property procedure is not part of the
syllabus.
Sub-procedures. and frrhctio*proccdunes ane also called general procedures.
ln the figure below (Fig. 12.7) we illustrate how an event procedure may call a
general procedure
\
156 tl?'t' Computer Systems and Applications - T.Y. B.Com.-(Sem. VI)
5 Code
--+
Key : Calling a procedure / function, Returning to calling program
Flg. L2.7 Illurtratlng how proccdures taay be ltnked
We now explore the working of the procedures with reference to this diagram.
i) When an event procedure is executed in response to an event, the code in
the event procedure starts executing at line 1, as shown in the figure
(Fig. 12.7) above.
i0 At line 2, there is a call to procedure A. So control is transferred to
procedure A, and the code in Procedure A starts executing.
iii) In Procedure A itself, there is a call to a function C. So control is
transferred from Procedure A to Function C. When the code of Function C
is over, control is transferred back to the Procedure A.
iv) When the code in Procedure A is over, control is transferred back to the
calling procedure which is the event procedure. Control is now at line 3 in
the event procedure.
v) At line 4 in the event procedure, there is a call to Procedure B, and so
control is transferred to Procedure B. When the code of Procedure B is
over, control comes back to the event procedure at line 5.
NEED FOR PROCEDURES AND FUNCTIONS
Although all Visual Basic programs will have a few event procedures, it is not
necessarJi to use sub-procedures and event procedures. But programming
becomes easier and more eflicient programs can be written by using sub-
procedures and functions.
Advantages of using procedures and fuactloas :
The advantages of using sub-procedures and functions are as follows :
o Avoid repetltlon of code : If there is identical code in tow or more event
procedures, it can be written just once in a procedure, and that procedure
can be invoked (called) from various places in tJ:e program.
o Improve code readablllty : If an event procedure is very lengthy and has
many lines of code, it is better to break up the code into smaller parts and
store this in many procedures. This improves the code readability.
o Re-ueability of code : If a particular code is required in many different
programs, it makes sense to write a procedure which can be called in any
program. For example, if there is a data validation code such as validating
Aduanced Feafures of Vbual Basic t't'tt' 157
the email address, then we can write a procedure called validate_email$
and use it in other programs.
o Ease of debugging programs : If a program is split up into smaller logical
units, it is easier to debug and detect errors. Code upgradation and
maintenance also becomes easier.
SUB PROCEDURES AND I.UNCTION PROCEDURES
In the above diagram (Fig. 12.7) we have used sub-procedures (Procedure A
and B) and a function procedure. There are two major differences between a sub-
procedure and function procedure :
i) A function procedure performs some action and returns only one data
item to the calling part of the program. This value that the function sends
back to the calling part of the program is called the return value. A sub-
procedure is a procedure that performs some action. It may not return
any value to the calling part of the program.
iil The way in which a function procedure is called is different from the way
in which a sub-procedure is called.
CREATING A NEW SUB.PROCEDURE
There are two ways to create a sub procedure or a function. One method is to
yourself write the entire code and the other method is to use a template to create
part of the code. We will use the second method - using a template.
Erample 1 :
In the following example, we will illustrate the concept of creating a sub-
procedure that changes the color of the form - from default gray to red, when the
user clicks a command button.
Step 1 : Start a new Visual Basic project.
Step 2 : On the form, place a command button.
Change the following properties of this command button :
Name: cmdChngColor.
Caption : Change Color
Step 3 : Double click on the command button to
open the code window. Tlpe the following code idd Procedure trl
in the event procedure for this command button:
Name;
Private Sub cmdChngColor-Click$ I
chgColor Cancel
End Sub
In this event procedure, notice the line
chgColor. This is a call to the sub-procedure
called chgColor.
Step 4 : We now create the sub-procedure called l- lll tocal vaiiables as statics
chgColor. Keep the code window open.
fig. 12.8 : Uslng the Add
Select Tools ) Add Procedure. The following Procedurcdidog bor to add a new
window (Fig. 12.8) appears : , geaerd procedure
Step 5 : In the Add Procedure dialog box, type
the name of the procedure as chgColor.
Step 6 : Select Scope as Private.
Step 7 : Leave the ffie as Sub and click on OK.
\
158 tt't"t' Computer Sgstems and Applications - T.Y.B.Com.-(Sem. VI)
Prr:ject1 trf
Show Date
o{(
Flg. L2,9 : Ruanlag thc program to dtepley the curroat tyrtem date
Aduanced Features of Wual Basic t"r'lr' 159
Called Procedure
Calling Procedure
X=X+20
Dim XAs Integer
X=10
Print "X is " & X
MyProc X
Output:
Output:
Xis10 Xis30
In the calling procedure, X has the value 10. We cdl the procedure MyProc
and pass the value X to it. In the called procedure, the value of X is increased by
20 and it becomes 3O inside the procedure MyProc. But when control returns
back to the calling function, X again has the value 1O. Thus, the called function
has changed the value of X but this change is not visible in the calling function.
How is a variable Passed bY Value?
To pass a variable or parameter by value to a procedure, we simply state the
narne oi th. variable afterlhe narne of the called sub-procedure. Thus, to call the
procedure MyProc and pass the value of the variable X to it, we will invoke the
procedure foUo*", tUyeroc X. In the called procedure, we must speciff the data
'type ""
of the passed variable as follows : MyProc (Byval X As Integer). The name of
th" specified in the called function can be different from the name
"rgrr-ent
specifiJd when ihe procedure is invoked. So we can write MyProc (Byval X As
160 t??' - T.Y.B.Com.-(Sem' VI)
Computer Systems and Applications
Integer) as MyProc (Byval Y As Integer), and use the variable Y inside MyProc.
The following example illustrates this concept of passing argument by value:
Example:
Create a new VB project with the following objects and properties as shown
below:
ObJect Property Value i Forrrrl uatr
Button Name cmdCallFn
Caption Call F\rnction
Label1 Name Labell
Caption
Label2 Name Label2
Caption
CrtFrrdim
Labe13 Name Label3
Caption
Code :
MyProc X
procedure MyFroc : 30
Cdl Function
Fig. 12.1O
Aduanced Feafires of Visual Basic t"t,t, 161
A sub-procedure may be called with one or more arguments. But the number
of arguments, their sequence and their data types must match in the calling
location and in the called location.
Example
Consider a call to a function PrintValue as follows :
PrintValue(P, R, T), where P, R and T are all integer data types representing
the principal amount, interest rate and time period respectively.
In the called part of the code we must write :
Private Sub MyProc(P as Integer, R as Integer, T as Integerf
But the following is invalid since only two parameters are specified in the
called part of the procedure.
Private Sub MyProc(P as Integer, R as Integerf
PASSING ARGUMENTS BY REFERENCE
When we pass an argument by reference, we are passing the address of the
argument to the called procedure. This is the default way of passing arguments
to a procedure. Every variable is stored in the primary memory (RAM) and every
location in memory has a fixed address. If the called procedure knows the
address of the variable, it can change the argument's original value. Hus, if we
pass an argument by reference to a called procedure, its value can be modified by
the called procedure. So when control returns to the calling procedure, the
variable may have a new value. This is illustrated in the following diagram:
MyProc (x)
Called Procedure
Calling Procedure
Dim X As Integer
X=X+20
X=10
Print "X is " & X
MyProc X
Output:
Output:
Xis30 Xis30
How is a varlable passed by Refercnee?
To pass a variable or parameter by reference to a procedure, we state the
name of the variable after the narne of the called sub-procedure. Thus, to call the
procedure MyProc and pass the value of the variable X to it, we will invoke the
procedure as follows: MyProc X. In the called procedure, we must speciff the data
type of the passed variable as follows: MyProc ( ByRef X As Integer). The name of
the argument specilied in the called function can be different from the name
specified when the procedure is invoked. So we can write MyProc (ByRef X As
162 f;f;t @n'ptW Sys&,nrs andAppliations-T.Y.B.Com.-(Sem. V0
Integer) as MyProc (ByRef Y As Integer), and use the variable Y inside MyProc.
The following example illustrates this concept of passing argument by value :
Exenple:
Create e new VB project with the following objects and properties as shown
below:
ObJcct Propcrty Vduo r l,,trrt1 X
Button Name cmdCdlFn
Caption Call Arnction
Label1 Name Labell
!u
Caption
I,abel2 Name Label2
gD
Caption
Label3 Name Label3
4'
Caption
Codc:
Hvate Sub
Dim X As Integer
X= 1O
Labell.Caption = "X before leaving the procedure s -
"cmdCallFn-Click() : " & X
MyProc X
Label3.Caption - "X after entcriqg Ore procedure " _
"cmdCallFn-Click$ : " & X
End Sub
Hvate Sub fyProclByRof tr Ar htiralrl
X=X+20
Label2.Caption = "X inside tlle proeedure MyProc : " & X
End Sub
r l,'rrrrl - f-fx
When the user clicks the command
button, the window shown below in
Fig 12.11 is displayed. Note that the value
of the variable X is 10 originally but is
changed by the procedure MyProc. When we
display the value from the original
procedure, after returning from MyProc, the
value displayed is 3O. Thus, changes made
by the procedure MyProc are now
permanent.
tl3. 12.11 : Eficct of plrrla3
erguncatr b5r rclcrclcc
Aduanced Features of Visual Basic t'r't' 163
FUNCTION PROCEDURES
A function procedure is a procedure that performs some action and also
returns a value to the calling part of the program. The value that a function
procedure returns is called its return value. We must differentiate between a
sub-procedure and a function procedure: a sub procedure only performs a set of
actions, but a function procedure also returns a value. A function procedure is
also called a function.
Visual Basic has two types of functions :
o Bullt-in functions : these are predelined in the Visual Basic language
and can be directly used without worrying about their internal code.
o User-deflned functlons : these are functions written by the programmer.
IIow to Write hraction Procedure or a Functioa?
A function is written in the same way as a sub-procedure. The word Function
is used in place of the word Sub when defining a function
To create a new function procedure :
Step I : Start a new project of type Standard EXE.
Step 2 : Place the objects and set their properties as shown in the table below :
ObJect Property Vdue ObJect Propetty Value
Button Name cmdCalc Label 3 Caption Number 3
Caption Calculate Label4 Name lbLAvg
t Forrnl tr x
lblNuml brtNumL
lblNum2 fttNum2
lblNum3 brtNum3
lblAvg brtAvg
cmdCal
F.tg. t2.t2
A = Val(txtNuml.Text)
B = Val(txtNum2.Text)
C = Val(txtNum3.Text)
r Sinrple lnterest tr tr
lblPrn
txtPrn
lblRate
bGRate
lblTime
brtTime
+- shpline
lbllnteres txtlnterest
Cahri$e
cmdCal
displayed:
Example : Write Visual Basic code with the lntaest Bde
Step 2 : Run the program and veriff the results. i Swap l'{unrbers
Erample: . 0rbindVakres . . SwappedVatres . .
lblNuml.Caption = A
lblNum2.Caption = B
Ead Srib
Private Sub Swap(ByRef A As Integer, ByRef B As Integer)
Dim Temp As Integer
'exchange values of A and B by using a temporar5r variable
Temp = A
A=B
B = Temp
End Sub
Aduanced Features of Visual Basic f"1t n 169
Step 3 : Run the program and veri$r that the output is correct.
Note : In this program, we are passing arguments by reference since we want
that any changes made by the procedure Swap should be permanent. Swap gets
the address of the two variables A and B and so when the values are exchanged,
they are done in the original location of A and B. These changes can then be
observed as we print these values again in the click event proced.ure.
USER.DEFINED SUB PROCEDURES IN BRIEF
User defined sub procedures
is a collection of 2 or more lines of code that can be invoked from one
or more places in the progr€rm
create when duplicate code will be used several times within the
program
to create a new sub procedure,
o OPEN the CODE window
click TOOLS
click ADD PROCEDURE
o give it a meaningful name; e.g., Factorial
a select Sub
o cnd select Private
code cannot be executed unless specifically CALLED from another
procedure
o it will be CALLED from other EVENT procedures
PROGRAMMING EXERCISES
1. Write a simple Color dialog box application that lets the user display a Color
dialog box simply by clicking a command button. When the user selects a color
and closes the Color dialog box, set the command button's BackColor property to
the user's selected color.
2. Write a function called CalcArea that computes the area of a rectangle.
Arguments received by the function are the length and breadth, both of data type
Integer. Write the appropriate code in the click event of a command button that
will execute the code in the function CalcArea. The area should be displayed by
the Click event procedure. Area of a rectangle = length x breadth
3. Write a function ChangeCurrency that accepts two arguments: one argument
is the amount in Indian Rupees, and the other argument is the exchange rate for
conversion from Indian Rupees to US Dollars. Select arl appropriate data type for
both these arguments. The ChangeCurrency function should convert from Indian
Rupees to US Dollars. The C1ick event of a command button should display the
result in a label.
4. Write a function Factorial that computes the factorial of a number entered by
the user. The input is given by the user in a text box, the factorial calculation
must be done by the Factorial function and the output must be printed in a label,
through the click event of a command button.
5. Write an event procedure in VB to lind the sum and average of "n" numbers
given as input.
6. Write a Visual Basic program to compute the GCD and LCM of two integers
entered by the user. The GCD and LCM should be calculated by a function called
GCDLCM.
17O t|"t"t" - T.Y.B.Com.-(Sem. VI)
Computer Sgstems and Applications
OBJECTIVE
12. Passing by value is the sarne as sending a copy of the variable to a sub-procedure.
13. A sub-procedure can be called only with one argument.
14. Global variables can be shared by all procedures of a program.
15. Global variables should be used as much as possible.
U. Multiple Choice Questions
Select the approprlate optioa from the followiag :
1. Of these, is not a valid Show method of common dialog box.
a) ShowHelp b) ShowPrinter
-
c) ShowColor d) ShowDrives
2. procedure is the procedure that is executed in response to events such as
mouse click.
- Property procedure
a) b) Function procedure
c) Event procedure d) Sub procedure
3. Variables can be shared by different procedures ofa program ifthey are _
a) Declared as global variables b) Passed by reference
c) Passed byvalue d) Any ofthe above
4. Common dialog box _
a) is a way by which Visual Basic program can translate the text on the screen into
another language.
b) displays the predefined Windows dialog boxes for print, open, save, fonts, and
colors.
c) can only be used on message boxes that will pop up and prompt the user for text
input.
5. The prefix for naming a menu item is _
a) m b) mnu
c) men d) mne
6. Which of these is an advantage of using procedures and functions?
a) They improve code readability b) They help in code re-usabitity
c) Debugging becomes easier d) All of the above
7. Every procedure is terminated by the statement.
a) End b) End Do
c) End Subforms with menus. d) allows you to create
AduancedFeafires of ViatalBasic fg.19. t7t
8. When it is desired that a menu item does not appear at run time, it must be ensured
ttrat the following property/properties must be set to false
a) Enabled b) Visible
c) Both Enabled and Visible d) Both Checked and Visible
9. What is the final keynord used to indicate the end (compilation) of a sub procedure?
a) End Sub b) Exit Sub
c) End d) None ofthe above
f O. Which of the only event for a menu control is available?
a) Load b)
Resize
c) Click d)
KeyPress
11. When variables are passed by reference (ByRef) to a SUB program,
a) only the memory addresses of the variables are passed.
b) a value of a variable is passed.
c)
a copy of the variable is passed.
d)
none ofthe above
12. When creating a menu, how do you create a menu separation bar:
a) In the Caption text box, enter an ampersand (&)
b) Select Menu Separator check box
c) In tJre Caption text box, enter a hyphen (-)
d) In the Caption text box, enter the text "Separator'
lArrswpRsl
I. [True : l, 4,7,9, I l, 12, 14
False 22,3,5,6,8, 10, 13, 15]
III. [(r-d), (2-d), (3-d), (4-b), (5-b), (6-d), (7 -cl, (8-b), (9-a), (10-c), (11-a),
(12 - c)l
OUESTIOITS
1. E:rplain the difference between a menu and a sub-menu.
2. What is a separator bar and how is it created?
3. E:rplain tl:e naming convention for a menu and its sub-menu.
+. State the steps for adding the common dialog control added to the tool box.
5. What does the term oommon dialog box mean? OR What is the purpose of a Dialog
Box Control in Visual Basic?
6. What is the use of the common dialog box control?
7. How many difrerent dialog boxes can the Common Dialog Box control produce?
8. Explain the Menu Editor window.
9. Differentiate between passing parameter by value and passing parameter by
reference. Illustrate with an example.
lO. What is the disadvantage of declaring a variable as a global variable?
Cft,'
172 g'r'l'' Computer Sgsfems and Applications - T.Y.B.Com.-(Sem. VI)
Syntax:
Formatl: Format2:
Do (While I Until) condition Do
'statements of the loop 'statements of the loop
Loop Loop (While I Until) condition
Execution of a Do/Loop continues while a condition is true or until a
condition is true. This loop is used when the exact number of iterations is not
known.
The loop condition is evaluated to determine whether or not to execute the
statements within the body of the loop. The condition must evaluate to True or
False and relational operators such &s (, ), <=, etc are used in the condition.
Difference between operation of lPhlle loop and Until loop : In case of the
do/while loop if the condition is True, the statements in the body of the loop are
executed. But in case of do/until statement, the statements are executed if the
condition is False.
If the condition is checked at the beginning, of the loop (as in format 1
above), the loop may not execute at all. This is called pre-test since the condition
is checked at the beginning of the loop. But if the condition is checked at the end
of the loop (as in format 2 above), the loop is executed at least once. This is called
post-test since the condition is checked at the end of the loop.
Examples of Do Loop :
o Do Until/Loop Example :
Counter = 1
Do Until Counter > 10
Print Counter
Counter=Counter+ 1
Loop
This loop repeats Until the Counter variable exceeds 10.
Visual Basic Loops ,"t?' 173
. Do/Loop While Example:
Sum=1
Do
Print Sum
Sum=Sum+3
Loop While Sum <= 25
This loop repeats while the variable Sum is lesd than or equal to 25.
o Do/Loop Until Example :
Sum=1
Do
Print Sum
Sum=Sum+3
Loop Until Sum > 50
This loop repeats Until Sum is greater than 5O.
o Do While/Loop Example:
Counter = 1
Do While Counter <= 1000
Print Counter
Counter=Counter+ 1
Loop
This loop repeats as long as (while) the variable Counter is less than or equal
to 10O0.
For / Next Loop
The For/Next loop is used when a group of statements is to be repeated a
specific number of times. This loop uses a variable called t}re loop index. This loop
index determines the number of times the loop will be executed. The loop is
executed as long as the initial value is less than or equal to the final value.
General Syntax:
For indexuar = initial-ualueTofinal-ualue [Step svalue]
Statements
Next lindexual
Example 1 :
ForI=1To5
Print I
Next I
Comparing this loop with the general syntax :
Indexvar is I, initial value is 1 and final value is 5. In this example, there is
only one statement inside the body of the loop. The step value is not given in this
example, so step value is assumed to be 1. Step value is the value bywhich the
value of I is increased. In this case, I will increase by 1 after each iteration.
When the For statement is reached, the initial value of I is set to 1. This value
is compared to the final value i.e. 5. If initial value is less than or equal to 5, the
statements in the body of the loop are executed and control reaches the
statement Next I. This statement increases the value of I by 1, so I becomes 2.
The new value of I is again compared with the final value (5). As long as the initial
,l
174 3l"t"jl' Computer Systems andApplications -T.Y.B.Com.-(Sem. VI)
value <= final value, the statements inside the loop are executed. So in this case,
the output will be :
1
2
3
4
5
At the end of the For/Next loop, the value of I is 6, since it is incremented by
the Next I statement.
If the condition initial-value <= final-value is not true, then the for loop is not
executed.
Example 2 :
ForI=1to10Step2
Print I
Next I
In this example, I is initially 1. Since this is less than the final value (10),
statement inside the loop is executed and value of I is printed. I then becomes 3
since it is increased by step value 2. As indexuar (31 <finat-ualue (lO), condition is
true and the body of the loop is executed to print 3. The successive values of I are
1, 3, 5, 7, 9. When I becomes 9, it is incremented (increased) by 2 so the new
value of I is 11. Since 11 > 10, the condition that the index variable should be
less than or equal to final value is no longer true and the statement inside the
loop is not executed now. Thus, the output of this program is :
1
3
5
7
9
Example 3 :
ForI=1to1O
PrintI, I*I
Next I
This loop will execute 5 times. For each value of I, the body of the loop will
print the value of I and I*I (i.e., I2). so the output of this code will be :
11
24
39
416
525
Example 4 :
ForI=6tol
Print I
Next I
In this case the initial value of I is 6. Since the condition initial-ualue<= final-
ualue is not satisfied, the loop is not executed at all and control passes to the
statement after the Next I statement.
Visual Basic Loops t?'t, 175
Important Points while using the For l,oop :
1. If the step value is not specified, it takes the defaurt value 1.
2. If the step value is positive, then the loop is executed as long as the following
condition is satisfied : initial-ualue<= final-ualue
3. If the step value is negative, then the loop is executed as long as the following
condition is satisfied : initial-ualue>= finol-ualue
4. It is not advisable to change the value of the index variable inside the body of
the loop.
5. To exit the For loop, we use the statement Exit Fotr inside the body of the loop.
This will transfer control to the statement after the /Vert statement of the For
loop.
Example 5:
Write Visual Basic code to accept the user's name in a text box, and print it 5
times.
Dm I as Integer
Dim strName as String
strName = txtName.Text
ForI=1toS
Print strName
Next I
MESSAGE BOX
MsgBox is used to display a message or the value of a variable (the result of a
calculation) in a box. We now explore the MsgBox function in detail.
General S5rnta.r :
MsgBox (Prompt, [,Buttons] [,Title])
tsgBor Functloa Return Vdues :
The message box function returns an integer value to indicate which button
was pressed. The return values are represented by Visual Basic intrinsic
constants as shown in t]le table below :
Vkual Baslc Value Button Pressed
Intrlnslc Constant
vbOk I OK
vbCancel 2 Cancel
vbAlert 3 Alert
vbRetry 4 Retry
vblgnore 5 Ignore
vbYes 6 Yes
vbNo 7 No
Speci$lag the Buttons to Dlsplay :
We can speci$ which buttons to display by using Visual Basic intrinsic
constants or equivalent numbers.
Button to Display Value Vlsual Basic Constant
OK button 0 vbOKOnly
OK and Cancel buttons 1 vbOKCancel
Abort, Retry, Ignore buttons 2 vbAbortRetryIgnore
Yes, No, Cancel buttons 3 vbYesNoCancel
Yes and No buttons 4 vbYesNo
Retry and Cancel buttons 5 vbRetryCancel
176 ft'j. Computer Sysfem.s andApplications -T.Y.B.Com.-(Sem. VI)
PROGRAMMING EXERCISES
1. To compute the Factorial of a Nunber:
Write Visual Basic code to accept a number from the user and calculate its
factorial. Print the factorial in a message box. [Note : Factorial of a number is the
productof allnumbers from l tillthatnumber. E.g., factorialof 4 is 4 x3 x2x I,
ie., 241. while running this program, do not enter a number greater than 7.
Form Design:
r Factorial xl
lblNum Erter a Number
t<tNum
cmdCalc Exit
cmdExit
cmdClear
Ftg. 13.3
Visual Basic Loops ,?'t' 177
Code:
'Purpose: To compute the factorial of a number
'Author: Mukesh N Tekwani
F= f initialiseFto 1
N = Val(txtNum.Text)
ForI=1ToN
F=F*[
Next I
cmdCalc cmdExit
cmdClear
Ftg. 13.4
178 l't't' Computer Systems and Applications - T.Y.B.Com-(Sem. VI)
Code:
?urpose: To compute tJre sum of numbers upto N
'Author: Mukesh N. Telsrani
Hvate Sub cmdCdC-Cttcl(f
Dim I As Integer
Dim N As Integer
Dim Sum As Integer
Sum=O
N = Val(b<tNum.Text)
ForI=1ToN
Sum=Sum+I
Next I
lauEsrrorsl
1. Define the terms "loop" and "iteration".
2. Explain the working of the Do/While loop.
3. Explain the working of the Do/Until loop.
4. Explain the working of the For/Next loop.
5. What is the purpose of the MsgBox function?
6. Rewrite the following code using For ... Next loop.
Dim I as integer
I=25
Do while (I>l)
Print I
I=I- 1
Loop
7. Differentiate between do while loop and do until loop of visual basic giving suitable
example.
8. What is a looping statement? Differentiate between an entry controlled and exit
controlled loop.
g. Rewrite the following code using For...Next statement without affecting the output :
Loop
l3/T.Y.B.Com - Com. Sys. & Appl. (Sem. - VI)
180 t"t't" Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
PROGRAIIIMING
1. Create a project to print odd (even) numbers in the range L to 2O.
2. Create a project to print the sum of odd (even) numbers between 1 and 50.
3. Write the Visual Basic code to print all numbers in the range 1 to lOO that are
divisible by 5. Use the Do/WhiIe loop.
4. Create a project to print the following table (upto N = 1O) :
r??'
Practicals t't't' 181
PRACTICALS
PRACTICAL 1
PREPARING A POWERPOINT PRTSENTATION ON AIT E.COMMERCE
WEBSITE
PRACTICAL 2
SAL/TRY CALCULATIOIT
Calculation of DA, HRA, PF, Gross Salary and Net Salary using MS-Excel.
Prepare a worksheet containing Names and Basic salary of 5 employees as
shown below.
.d
\*
186 3l't'C Comlruter Sgstems and. Applications - T.Y.B.Com-(Sem. VI)
PRASHCAL 3
IITCOUE TAX CAI,CULATIOIT
Step 2 : Save the workbook: After typing the data, click on the Office button
and Select Save As.. option from the menu. Save the workbook with the name
MONA1232. Replace MONA with your narne, 123 with your ro11 number, but keep
the last digit 2 as it is the practical number. Then, click on Save. The file will be
saved with name you gave. The filename extension ryilIbe .XLSX.
Part 2 : To do the income tax calculatlon ln column C:
Step 1 : Click on cell C2.lt becomes the active cell. Now type the following
formula in the Formula bar :
=IF(B2<=lOOoOO, O, IF(E}2 <= 160O00, (82'1O0OOO)*107o, IF(82 <= 23OO0O,
60000*10% + (82-160000)*20%, 60000*10% + 700OO*2Oo/o + (82-230000)*30%)))
This becomes the formula for cell C2.
188 fft" @tnputcr Sgstems and Applicafions - T.Y.B.Com--(*m- VI)
Step 2 : Select cell C2 and drag the Fill Handle (the littte black square on the
lower right of the ce11). Drag till you reach cell C26. Release the mouse button.
The tax calculations for each employee appear automatically. The formula for
each cell has changed so that it refers to the appropriate cells in each row.
Alternatlvely : Click on cell C2, keep SHIFT key pressed, and use the down
arrow key to go up to cell C26. Release the SHIFT key and press CTRL + D. This
will also copy the formula in all cells up to C26 and adjust the formula
accordingly.
The worksheet appears as follows :
Bic E
1 Name Taxable lncome IncomeTax Surcharge Tax
Amit 98(m0 o
Priya 158tx)O 58{X)
Meenakshi 193(n0 12600
5 Mumtaz zrH(m 24500
6 Dipti 5400m [:ilm
1 I
PRACTICAL 4
FILTERIITG DATA.AITD GRAPHICAL RTPRESEITTATION OF DATA
S lloruarz:r
A B C n F
Step 2 : Save the workbook: After typing the data, click on the Office button
and Select Save As.. option from the menu. Save the workbook with the narne
MONA1231. Replace MONA with your narne, 123 urith your roll number, but keep
the last digit 1 as it is. Then, click on Save. The file will be saved witJr name you
gave. The filename extension will be .XLSX. In case you get the following error:
il
ar&.t
The t&e ltlot'lAlz3l,xlsx dready exists. Do you want to redace the existirg fb?
Tr* I ruG"-T
F\. P4.22 File Save Error
It means that the file has already been saved by that name -by you or
someone else - so save the file with your name.
Pradicals rr?'t " 191
$ MM
Sm
Pa.-rlS
Flg. P4.5: Selecthg the 3-D Ple chart
192 I't'!o Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
Total Marks
Amit
Priya
' ..
k,, .,,,''
.::.:,
,' Meenakshi
I Mumtaz
Line Chart
100
80
P60 1
G
=40 -Subject
*Subject 3
20
0
t 2
I2
AI lAlzl
zt
zt
IzlAl
-
Sort
YFtlter
'{''
{;
f,lear
neappty
3
56
23
67
72
188
37
AT
Sldvanced { 81 85 2rl9
Sort & Filter 5 61 59 w
Ptg. P 4.8 : Eclcctlng Flltcr optlon ng. P 4.9 : Sclcc+lng Flltcr optlon
AI
zl Sort Smallcrt to !a.gc5t
zt
A' 59rt larg.rt to Smrllcst
Sor! by Color I !
I
l.
I
i
,
tlumber Eitter! I Eqmts.,,
BctUCCn,..
Iop 10,..
AboYe AYcragc
Custoil Eiltcr..,
Custonr AutoFiltet ? x
Show rows r#herel
Total lila*s
is greater than 18ol
OAna OE
OK Cancel
5 67 61 59 187
PRACTICAL 5A
USE OF VLOOKUP
Prepare a worksheet containing the Name of the salesman and sales for the
months of January, February and March in columns A, B, C and D respectively
from rows I to 26, the first row contains headings and the remaining rows
contain data. Use your own data ensuring that the sales entered in a month are
minimum 100000 and maximum 300000.
Carry out the following operatlons on this worksheet :
1. Enter the following Bonus Table in columns H and I.
SALES BONUS
300000 2000
400000 3000
500000 4000
600000 5000
700000 6000
800000 7000
2. Save the worksheet under your name followed by your roll no., question no.
e.g. MONA1235
3. Obtain the total sales of each salesman in the first quarter in column E.
4. Using VLOOKUP function obtain the bonus amounts to be given to each
salesman in column F.(Note if the total sales are say 319O0O, which is above
300000 and below 400000 then the Bonus amount will be 2000)
Part 1: To create a new file and save it
Step 1 : Open a new workbook and type the data as per instructions given in
the question. A part of the worksheet looks like this (we have shown data only for
11 employees and 4 departments, but you may enter more data as per the
question)
Data Validation Step : As given in the question, we have to ensure that the
sales entered are a minimum of 5000O and a maximum of 2500O0. To ensure
that this condition is met, we will lirst put this data validation in the range B2:
. D27.
How to put data validation in cells B2:D27?
a) Select the range B2:D27 by pressing the function key F5. A "Go To" dialog
box pops up. In this dialog box, t5rpe B2:D27 in the Reference textbox.
The range B2 to D27 is highlighted.
b) In Excel click on Data menu, and then click on Data Validation. The
following dialog box pops up :
Oata Validation
Err Alert
Ydd*irr rterb
dfowr
vdue [Jtgroretla*
t e.'q] sx Cryrd
1 Name Jan Sales Feb Sales Mar Tetal Sales Bonus Sales 3ofius
2 230000 60000 300000 xx)o
r53om 900m {f,0CI00
4 1{XXx)0 2{XXm0 55000 5ffim0 'Xm
anxn mq0o0 6fin0 6fiXxt0
5 Mumtar 2flXx)o 201000 22fiXlO 6qn
7 250000 23{XDo m000 7ux,
I Dilip 65000 eo0{n0
9 7&t00 990m 1990m
Nikhil 2500m 250fin :50000,
1I NNmrsta 198000 :4flD0
12 Bhavlka 2X)500 25{nX}
A E:C D E
t Jen Ssles Feb Sales Mar Sales Tot{l s6les B+nus Sales Bonus
2 230000 60000 s3000 343000 30mm ?000
3 155000 9{too0 100000 345000 400000 3{m0
4 li 100000 xt0000 5s000 355000 sfiXm Itfilo
5 z(nm 100ffn 360000 sqry:
6 Mumt€z 20000s 2010m 621000 qqq$.
7 250m0 23{I(m 730Ur0 TTn,J
8 Dilip 65000 20m00 190000 455000
9 Pankaj 78000 99000 1990m 376000
10 Nikhil 250000 250000 250000 750000
11 Namrata 250000 x99000 894{mO
l2 Bhavike 240060 220500 250S00 710560
1 Jan Sales Feb Sales MarSeles Total Sales Bcnui Sales Bonus
2 230frX) 6fix)0 53mO 3430fi) 2000 ilxxno zqx]
3 Anita 1550fi' 9fin0 lfiXXtO 3rt5(x)0 ano 4{XXX)O 3{m0
4 10(nfi] zfixx)o 55004 355{n0 ?000 s{XXx)O 4000
5 Veena 20fim{} 1fi)000 60000 36fim0 zCIoo 6{XXX}0 5000
5 Mumtaz ?o1000 z?qqry 621t)00 ryqq 70qn0 600&i
7 250000 t300m 2SI00tt 73(xm 6{rc0 s00{n0 7CI00
I Dilip 65000 zfiro(x) 190m0 45sun 3000
I PankaJ 78000 99000 19€000 376{m
10 Nikhil 250000 2500@ 25{ms0 r50(n0 qgm
11 Narnr8ta e50000 19flI00 44p000 6840m ffi.
1? Bhavika e40(Ml 120500 150{p0 710560 6000
\,
198 l,'t''r" Computer Sys/ems and Applications - T.Y. B. Com.-(Sem. VI)
PRACTICAL 58
USE OF HLOOKUP
Prepare a worksheet that contains names of currencies, countries and cities
as shown below. User can enter the currency name in cell 89, and the HLOOKUP
function will be used to display the corresponding country name and city name
in cells E}6 and E!7 respectively.
I
d( A E
I
5 I I
6 Country I
7 City I
I I
l I
9 Currency
PRACTICAL 6
CREATING AND MANAGING A SCENARIO
Cell D15 : Type the formula =D3-814 Fig. P6.1: Income and Expeaditure
We will create a scenario to study the
effects of various budget cuts and how it increases the available balance.
Step 1 : Click on Data Menu ) Data Tools ) What-If Analysis ) Scenario
Manager.
Pract 6xlsx - Microsoft Excel
Dita
#s Edit Linki
Goat leek...
Data Jable,,,
f-ffi
Delete
Ldrt.,,
5ummdry
Changing cellsl
Show Close
Step 2 : We want to create a new scenario. So click the Add button. You'Il
then get another dialogue box as shown in Fig. P6.4
Add Scenario Etrt
scenario Eame:
K17
E
n nid"
Cancel
Qelete
Edit., ,
Merge,.,
Fqffi-l
ChangirE ce$s: $B$7:$E$e
Comment: Created by sYsTEIvl3 on 10i28i2014
2590
Type a new Name as Budget Two. The $B$s
click OK. You will again see the Scenario add Cancel
values dialog box. Now we will change the
values and the new values are as shown in Fig p6.7: New values for Budget
Fig. P6.7:
Scenario Manager Dialog Box looks like this now :
Scenario lrdanager
trlEl
slenariosi
add,
Qelete
f-r;-l
t-l
Berge.
Fffi*"I
Changing cek:
Commant:
r*ffi*l Close
Dls, Bl4, D3
IoK,l Cancel
\
2O2 3l"t't' ComputerSyslems and Applications -.T.Y.B.Com.-(Sem. VI)
In Results Cell, we have type D15, 814 and D3. These are the cells which we
will use in our report. Click OK. The Scenario Summary Report is as shown in Fig
P6.10. This Summary appears in a separate worksheet which has the name
Scenario Summary.
Eil F G
1
Summary
3 [urrent Va:ue5: or
7 tBls
9
1t) T'o{J 45m TN
11 42300 455fi) 42300
13 vlofi) 50000 5{Xn0
13 Notes: Current Values column represents values ofchanging cells at
}t time Scenario Summery Report was created. Changing cells for each
15 scenario are highlighted in gray.
16
't
I
Practbals nff X 203
PRACTICAL 7A
USE OF GOAL SEEK
Goal Seek feature is used to get a particular value when we are not sure of a
starting value.
Example 1:
Let us consider a very simple exarnple. Suppose we want tJ:e product of two
numbers to be 75 and we know that one of the numbers (say A) is 15. What will
be the other number? This may seem like a trivial example, but will illustrate the
concept of Goal Seek. Here the God is 75. We are Socling the second number
(say B).
Step I : Create tJ:e following worksheet : ,d
fcnarlo lilmgrr,.,
D*t, Irblc.,
)
't-
204 n?'f' Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
Click OK. Excel displays the dialog box showing that it has found the
solution (Fig P7.5)
Gual Seek Status ? trl
5i*p
Pause
OK Cancel
A Fixed
B Unknown n
Result we want
In the Goal Seek dialog box that appears t5rpe Fig. P7.8
the values as shown in Fig P7.8: GoaI Seek
Practicals ;|"t|'t' 2Os
Set Cell: Tlpe F4. This is the cell we want to set to a specific value (our Goal).
To Value: Type 35000. (This is our Goal - we want a profit of t 35,000)
By Changing cell: lrpe F3. The value we ca.n is the item
(selling price). So we are telling Excel that we
want to Set (fix) the value in F4 to 35000.
Goal Seek Status ? m
We want Excel to calculate F3 to achieve this Goal Seeking with Cell F4 Slen
value. So we are Seeking the value of F3. found a solution,
Pause
Click OK Target value: 35000
PRACTICAL 7 B
USE OF SOLVER
Installlng Solver :
If the Analysis toolbar does not appear, or does not have the "Solver" button,
the add-in must first be activated.
Follow these steps to activate Solver :
1. Click on the Office button in the top left corner
2. Choose "Excel Options"
3. Choose Add-Ins in the left side vertical menu.
4. In the Manage box, click Excel Add-Ins and click Go...
[xcel Options nE-l
Popubr i.r
l/*
L-r,
FomuLt
Proofing Add-in5
Mamg?:
ox Can(cl
Iil
F$n.12 Eror lf Solver lt not lnrtalled
Practical"s t'lr't" 207
You should now get the Solver option as shown in Fig P7.I3
O!t!
.D E
1 Problem
2 I
1 Problem
2
Unit Cost Customer 1 Cugtomer 2 Custorner 3
4 Factory 1
Factory 2
6 Factory 3
I
I chih6^a{ Customer 1 Customer 2 Customer 3 Total Out
Factory 1 $ tl 0 o
Factory2 o o 0 0
Factory 3 o o o 0
Tota! ln 0 0 o
Total Cost
Demand .'::li:r:,,, &.,.,..,,,,
t'l
Fig. P7. 15: Traarpottation Problem
208 t't't'' - T.Y.B.Com.-(Sem. VI)
Computer Systems and Applications
Guess
(hange
fB"*t Ail I
Qelete
t- H-rF-l
When this dialog appears, Cell Reference and Constraint will both be empty.
C1ick inside "Cell Reference" and click on cell C14. Change the inequality from <=
to =. Click inside "Constraint" and click on cell C16. This tells Excel that the
constraint is value of cell C14 should be equal to value of cell C16.
Click on Add button and repeat the procedure for cells :
(D14 and D16)
(E1a and E16)
(G10 and I1O)
(G11 and I11)
(G12 and I12)
Click on OK. Dialog box as shown in Fig. P7.18 appears.
Solver Parameters EI
5et Target Cell:
Equal Tor O Nu* 0 Nic O gahe of : 0
Close
Ey fhanging Cells:
$c$10:$E$12 [uess
Step 5: Click on Options button in above dialog box. It brings up the Solver
Options dialog box (Fig. P7.19)
Solver Options tr
Max Time: |E*] seconds OK
Tolerance: 5 Model
In Fig P7.Lg, select "Assume Linear Model". Keep other settings as shown in
this Figure and ctck OK. You will again see the Solver Parameters dialog box
(Fig. P7.18).
Stcp 6 : Click on Solvc in Solver Options didog box. The Solver Results
dialog box appears (Fig. P7.2Ol.
Solver Results lxl
Solvar fourd a sd:tlsr. il cpnttr**s a-ld o*i*
cor*ims ue sffi, Rcpsts
Scnsitlvity
tirdts \
relI Crxd
7 I
i
I I
I
I I
17
f[.
Trurportetloa DloUcu Solvcdt
P7.21:
We can see that Total Out values match the Supply capacit5r of each factory.
Also, the Total In matches the Demand of each Customer. Total Cost is
minimized to 26000.
Try changing the values in the range C1O:E12, keeping in mind the
constraints in ranges G1O:G12 and C16:E16. You will observe that in all cases
the Total Cost is more than 26000 and Solver has got an optimized solution.
Visual Basic Practicals
Practicals n?'r' 211
PRACTICAL 8
Develop a project in VB to design a suitable form to add two numbers and
display their sum.
Solution :
Step 1 : Design the form as shown in Fig. P. 8.1 below.
t Projectl - Forml (Form) r!E']flrr
i Sum of Twu Variables
Numl
Num 2
5um
Qear
,, s:l 1,, n'- |
a = txtNumL.Text
b = txtNum2.Text
s=a+b
txtSum.Text = s
End Sub e
PRACTICAL 9
t Borus Calculation
Sales _l-
I
:l
I
falculate C!*a; ouit l::
t..
s = txtSales.Text
b = 0.1 * s 'bonus = lOo/o of sales
txtBonus.Text = b
End Sub
PRACTICAL 1()
Code:
'Purpose: DA Calculation
'Author: Mukesh N Tekwani
b = txtBasic.Text
da = O.9 * b 'since DA is 9Oo/o of basic salary
txtDA.Text = da
End Sub
i Mailing Labels tr x
First Name txtFName
Date o1 bftDOB
Sheet,Address
txtStrAdd
I--..
.. State
I
I
I
PIN Code
:.:...::_:::..:::::
Fig. P. 11.1
I
218 t"t"t" Computer Syslems and Applications - T.Y.B.Com.-(Sem. VI)
txtFName.SetFocus
End Sub
Pradicab ,'t'tf 219
Hvate Sub cmdDisplay-Cltck(f
'Display all the info as the caption of the label lbllnfo
lbllnfo.Caption = "Name: " & txtlName.Text & u' & _
txtFName.Text & vbCrLf
Caption = lbllnfo.Caption & "Date of Birth: " & _
brtDOB.Text & vbCrlf
lbllnfo.Caption = lbllnfo.Caption & "street Address: " &
-
txtStrAdd & vbCrlf
lbllnfo.Caption = lbllnfo.Caption &'City-State-Zip: " & _
txtCity
lbllnfo.Caption = lbllnfo.Caption & " & txtState
lbllnfo.Caption = lbllnfo.Caption & " & txtPIN
End Sub
Private Sub cmdPrint-Click(f
Printer.Print
Printer. Print Tab(2O) ; "Information"
Printer.Print ; lbllnfo.Caption
Printer.EndDoc
End Sub
PRACTICAL 12
In retail sales, management needs to know the average inventory figure and
the turnover of the merchandise. Create a project that allows the user to
il Enter the beginning inventory
ii) The ending inventory
iii) The cost of goods sold
On the form: include labeled text boxes for the beginning inventory, the
ending inventory, and the cost of goods sold.
After calculating the answers,
il Display the average inventory, and
iil The turnover, fornatted in labels
Include command buttons for : Calculate, Clear, Print Form, and Exit
The formulae for the calculations are :
Average Inventory = (Beginning Inventory + Ending Inventory) / 2
TurnOver = Cost of Goods sold / Average Inventory
Note :
il The average inventory is expressed in dollars, and
ii) The turnover is the number of times the inventory turns over.
Code : Include procedures for the click event of each command button.
Display the summar5r information in labels :
i) Format the average inventory as currency ,and
ii) The turnover as a number with one digit to the right of the decimal
Test Data:
Beginning Ending Cost of
Iaveatoty Iaventoty Goods sold
58,500 47,OOO 4,O0,OOO
Check Figures :
Average Turnover
Iaventory
52,750.O0 7.58
44,450.OO r 1.60
I 1,300.00 4.25
Practicals t ?,t , 221
Solution :
Step 1 : Design the form as shown in Fig. P. 12.1 below
lblEegtnlnv
lbllaput lblTurnOver
Bfirrnorer
lblAqglnv
EtAqhv
lblSummary
ftcost
txtEndlrv lblCost
bGBegintnv
lblEndlnv
Fig. P. 12.1
Controls and their propertics :
Object Property Value
Form Name frmlnventory
Caption Inventory
Label Name lbllnput
Caption Input Data
Label Name lblBeginlnv
Caption Beginning Inventory
Label Name lblEndlnv
Caption Ending Inventory
Label Name lblCost
Caption Cost ofgoods sold
Label Name lblSummary
Caption Summar5r
Label Name lbLAvgInv
Caption Average Inventory
Label Name lblTurnOver
Caption T\rrnover
TextBox Name txtBeginlnv
TextBox Name txtEndlnv
TextBox Name txtCost
TextBox Name txtAvglnv
TextBox Name txtTurnOver
Command Button Name cmdCal
Caption &Calculate
Command Button Name cmdClear
Caption C&lear
Command Button Name cmdPrint
Caption &Print
Command Button Name cmdExit
Caption E&xit
Line Name Linel
t
222 t't'3o Comgruter Sgslems andAppliqtions -T.Y.B.Com-(*m. VI)
Code:
'Purpose: Calculate average inventory and turnover.
'Author: Mukesh N Tekwani
q1 = Val(txtBeginlnv.Text)
q2 = Val(txtEndlnv.Text)
cost = Val(txtCost.Text)
q = (q1 + q2l /'2
turnover=cost/q
txtAvglnv.Text = FormatCurrency(q, 2)
txtTurnOver.Text = FormatNumber(turnover, 2)
End Sub
txtBeginlnv.SetFocus
End Sub
Step 3 : Run the program and check that the output tallies with that given in
the table above.
Practbals t't't" 223
PRACTICAL 13
Create a project that determines the future value of an investment at a given
interest rate for a given number of years. This method gives the compound
interest. The future value is the sum of principal amount and the accumulated
interest.
Future Value = Investment amount * (1 + Interest rate) ^ years
Use labeled text boxes for the amount of investment, the interest rate (as a
decimal fraction) and the number of years the investment will be held. Display
the future value in a formatted text box as currency. Include command buttons
for Calculate, Clear, Print and Exit. Format alldollar amounts.
Test data:
Amount Rate Years Future Vdue
2000 l5o/o 5 4,O22.71
1234.56 7.5o/o ? 1533.69
Solutlon:
Step 1 : Design the form as shown in Fig. P. 13.1 below :
i Future Value
lblPrn b<tPrn
lblRate
txtRate
lblYears
txtYears
IbIFV
txtFV
lblCalc cmdClear
lblPrint cmdExit
rE. P. 13.r
Step 2 : Ilpe the following code in the code window
Code:
?urpose: Calculate future value of an investment
'Author: Mukesh N Tekwani
Dim P As Double
Dim R As Double
Dim T As Double
224 l)'t'r' Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
P = Val(txtPrn.Text)
R = Val(txtRate.Text)
T = Val(txtYears.Text)
txtFV.Text = FormatCurrency(P * (1 + R) ^ T, 2)
End Sub
txtPrn.SetFocus
End Sub
Hvate Sub cndHnt-Click(f
PrintForm
End Sub
Step 3 : Run the program and veri$ that the output tallies with that given in the
table above.
Note, while entering the interest rate, type the rate in decimal fraction. E.g.,
if the interest rate is 15olo, t5pe 0.15.
Practicals t"l,?' 225
PRACTICAL 14
Write a project which provides the following income tax slab along with the
tax rates, irrespective of gender (male or female). Design a suitable form asking
for the monthly income and gender of a person. Finally calculate and display the
total tax and annual net pay of the person.
Annual Income Tax Rate o/o
o - 1,50,000 Nil
1,50,001 - 2,00,000 lOYo
2,00,001 and above 2Oo/o
Solution :
Step I : Design the form as shown in Fig. P. 14.1 below:
i Tax Calculation trtrrxl
lbllncome fraGender
frmTax optFemale
lblAnnual
txtAnnual
lblTax
brtTax
lblNetPay
txtNetPay
Ftg. P. 14.1
Note: First draw the frame fraGender by clicking on the frame tool in the
ToolBox. After that, draw the option buttons optMale and optFemale. Donot
doucle click on the option button tool in the ToolBox as that will simply place the
option button on the form; we want the option button inside the frame so that
only one of the two options is selected.
Coatrols and their properties :
ObJect Property Value
Form Name frmTax
Caption Tax Calculation
Label Name lbllncome
Caption Monthly Income
Label Name lbLAnnual
Caption Annual Income
226 t'r?" Computer Systems and Aoplbations - T.Y.B.Com.-(Sem. VI)
Note : The Enabled property of some text boxes has been set to False so that the
user cannot type anything in these boxes. The result of calculation is displayed in
these text boxes.
Step 2 : Tlpe the following code in the code window :
Code:
'Purpose : Tax calculator
'Author: Mukesh N Tekwani
Sub cmdCalc_Cltck{f
minc As Double 'monthly income
Dim ainc As Double 'annual income
Dim tax As Double
Dim netpay As Double
minc = Val(txtlncome.Text)
netpay=ainc-tax
txtAnnudl.Text = ainc
txtTax.Text = tax
txtNetPay.Text ='netpay
End Sub
txtlncome.Text = ""
optMale.Value = False
optFemale.Value = False
txtAnnual.Text = ""
txtTax.Text = ""
txtNetPay.Text = ""
txtlncome.SetFocus
End Sub
PRACTICAL 15
Solution:
Step 1 : Design the form as shown in Fig. P. 15.1 below :
r Text Formatting Ex
lblText
txtText
fraColor fraStyle
optRed chkBold
optGreen chkltalic
optBlue chkUnderline
cmdExit
Fig. P. 15.1
If chkBold.Value = l Then
txtText.FontBold = True
Else
txtText.FontBold = False
End If
End Sub
Private Sub chkltalic-Click(f
'if Italic check box is enabled, text is displayed in
ltalic otherwise it is displayed in Normal font
If chkltalic.Value = l Then
txtText.Fontltalic = True
Else
txtText.Fontltalic = False
End If
End Sub
Private Sub chkUnderline-Click(f
'if Underline check box is enabled, text is underlined,
'otherwise it is displayed in Normal font
If chkUnderline.Value = l Then
txtText.FontUnderline = True
23O al"t't ' Computer Systems and Applications - T.Y.B.Com.-(Sem. VI)
Else
txtText. FontUnderline = False
End If
End Sub
Private Sub cmdExit-Click(f
End
End Sub
Private Sub optBlue-Clickfl
'If Blue option button is selected, display text in Blue
'color. vbBlue is an intrinsic constant in Visual Basic
txtText.ForeColor = vbBlue
End Sub
txtText.ForeColor = vbGreen
End Sub
PRACTICAL 16
Develop a project which provides the following modes of transport and fares
per unit distance. After inputting the distance and mode of travel, the program
should calculate the total bill, and print it as a caption on a label.
Mode Fare
Railway t3perkm
Fight t4perkm
Car {Sperkm
Solutlon:
We assume that the journey can be completed by one or more modes of
transport. That is, part journey by railway, part by flight and rest by car. User
must enter tJ:e distance travelled by each mode and ttre program will calculate
the grand total amount. We will also display the total amount against each mode
of transports
Step I : Design the form as shown in Fig. P. 16.1 below :
t Billing Prugranr trtr
lblMsg
lblAmountnt
Distance Amsunt
fraMode >mo{Ie fi I Iivet-*-*"
lblTotalAmount
cmdClear
rig. P. 16.1
Code:
'hrtpose: Travelllng Nlowance (TAl Bill preparatlon
'Author: Mukesh N. Teksani
Private Sub chkCar-Cltck()
'if the chkCar check box is selected, display the
'corresponding text box txtCar for accepting distance (
If chkCar.Value = l Then
txtCar.Visible = True
txtCar.SetFocus
Else
2s2 rr3flr Compruter Sysfems and Applications - T.Y.B.Com.-(Sem. VI)
txtCar.Visible = False
txtAmtRail.Text = O
End If
End Sub
If chkFlight.Value = l Then
b<tFlight.Visible = True
txtFlight.SetFocus
Else
txtFlight.Visible = False
' txtAmtFlight.Text = 0
End tf
End Sub
If chkRail.Value = l Then
txtRail.Visible = True
txtRail.SetFocus
Else
txtRail.Visible = False
txtAmtcar.Text = 0
End If
Ead Sub
dr = Val(txtRail.Text)
df = Val(txtFlight.Text)
dc = Val(txtCar.Text)
'now calculate and display the amount for each mode
amtr=3*dr
amtf = 4* df
amtc=8*dc
'display these amounts in the text boxes
txtAmtRail.Text = amtr
PracticaLs t't'l,' 233
txtAmtFlight.Text = amtf
txtAmtCar.Text = amtc
txtAmtRail.Text = 0
txtAmtFlight.Text = 0
txtAmtCar.Text = 0
End Sub
txtRail.Text = ""
txtFlight.Text = ""
txtCar.Text = ""
txtAmtRail.Text = ""
txtAmtFlight.Text = ""
txtAmtCar.Text: ""
lblTotalAmt.Caption = "Grand Total"
End Sub
PRACTICAL 17
Piece workers are paid by the piece. Workers who produce a greater quantity
of output are often paid at a higher rate. Create a Visual Basic project with the
following specifications :
Form : Use text boxes to obtain the person's name and number of pieces
completed. Include a Calculate command button to display the dollar amount
earned. You will need a Summar5r button to display the total number of pieces,
the total pay, and the average pay per person. A Clear button should clear the
name and number of pieces for the current employee.
Include validation to check for missing data. If the user clicks on the
Calculate button without first entering a name and number of pieces, display a
message box. Also, you need to make sure to not display a summary before any
data are entered. You cannot calculate an average when no items have been
calculated. You can check the number of employees in the Summary event
procedure or disable the Summary command button until the first order has
been calculated.
Pieces Completed Hce patd per plece
for dl the pieces
L - 1,99 0.50
200 - 399 0.55
400 599- 0.60
600 or more 0.65
Solutlon :
Step 1 : Design the form as shown in Fig. P. 17.1 below
I Wage Calculation t;rE|Ir.l
lblSrNo
lblSerial
lblName brtName
lblPieces
brtPieces .
lbLAmount
lblSummary
I
cmdExit
I
cmdSummary cmdClear
Ftg. P. 17.1
Practbab l''l,"r" 235
Controls and thelr propettles :
ObJect Propcrty Vduc
Form Name frmWages
Caption Wage Calculation
Label Name lblSrNo
Caption Serial No.
Label Name lblSerial
Caption ""(blank)
Label Name lblName
Caption Name
Label Name lblPieces
Caption Pieces
Label Name lblAmount
Caption ""(blank)
Label Name lblSummary
Caption "" (blank)
TextBox Name txtName
TextBox Name brtPieces
Command Button Name cmdCalc
Caption Calculate
Command Button Name cmdSumamry
Caption &Sumamry
Command Button Name cmdC&lear
Caption Clear
Command Button Neme cmdExit
Caption E&xit
Step 2 : Tlpe the following code in the code window
Code:
'hrrpose : Wage calculatlonr
'Author: Mukerh If TeLsanl
p = 0 'initialisation
p = Val(txtPieces.Text)
lblAmount.Caption = FormatCurrency(amt, 2)
avgpay'= totalpay / n
End Sub
Practicals r,,'r' 237
Private Sub cmdSurnmary_Click(|
'display the summary
lblSummary.Caption = "Total no. of pieces: " & totalpcs &
vbCrLf
lblSummary.Caption = lblSummary.Caption & "Total wages: "
& totalpay & vbCrlf
lblSummary.Caption = lblSummary.Caption & "Average Pay: "
& avgpay
End Sub
Private Sub cmdClear_Click(f
'clear all object
lblSerial.Coption = ""
txtName.Text = ""
txtPieces.Text = ""
lblAmount.Caption = ""
lblSummary.Caption = ""
cmdSummary.Enabled = False
txtName.SetFocus
Step 3 : Run the program and test for different values of number of pieces.
\
238 l,'t"l," Computer Sg stem.s and Applications - T.Y.B.Com.-(Sem. V0
PRACTICAL 18
Write a project that calculates the total bill of hardware purchased from the
following list and cost :
Motherboard @t 4,OOOl-
CPU 2.9 GHz@ t 8,OOO/-
Hard disk 250 GB @ { 3,500/-
DVD Write @< 1,250/-
RAM I GB@< 1,25O/-
Cabinet @< 1,5OO/-
Monitor @< 7 ,OOO /-
Keyboard + mouse @< 75O/-
Input the quantity and display the total bill in a label.
Solutlon:
Step 1 : Design the form as shown in Fig. P. 18.1 below :
r llartlware flill l
I'x
::i:: :: :i Hardrrare-Billoffurchase i::::r;::ii:
It.m :: cod e$il&, Iotd
Mcrtherhosd Rgil.ffi1.
I
8s3.ffi/.
.. Rs1JW.
g-rry-
Mor$tor Er 7.il01-
:::::::
R* ?E0l-
...:,.:
[*r/d" I +a gd
rE. P. r8.1
t.
Practbals t'jl r, 23g
Controls and thelr properties :
(I give here the properties of only those controls that are required in the
codef
ObJect Property Value
For all these text boxes, the Text property is "' (blank)
TextBox Name txtMBQty
TextBox Name txtcPUQty
TextBox Name txtHDQty
TextBox Name txtDVDQty
TextBox Name txtRAMQty
TextBox Name txtCabQty
TextBox Name txtvDUQty
TextBox Name txtKybdQty
For all these labels, the Caption property is "" (blank)
Label Name lblMBQty
Label Name lblCPUQty
Label Name lblHDQty
Label Name lblDVDQty
Label Name lblRAMQty
Label Name lblCabQty
Label Name lblVDUQty
Label Name lblKybdQty
Label Name lblGrandTotal
Command Button Name cmdCalculate
Caption &Calculate
Command Button Name cmdC&lear
Caption Clear
Command Button Name cmdQuit
Caption &Quit
Line Name Linel
Step 2 : I}pe the following code in the code window
Code:
'hrrpose: Hardware Bill calculations
'Author: Mukesh N Tekwanl
tl = 4000 * Val(txtMBQty.Text)
t2 = 8OOO * Val(txtcPUQty.Text)
t3 = 3500 * Val(txtHDQty.Text)
t4 = l25O * Va1(txtDvDQty.Text)
t5 = 1250 * Val(txtRAMQty.Text)
t6 : 15O0 * Val(txtCabQty.Text)
24O ,'t'r" Computer Sgstems and Applications - T.Y.B.Com.-(Sem. VI)
t7 = 7 OOO * Val(txtvDUQty.Text)
t8 = 75O * Va1(txtKybdQty.Text)
lblMBTotat.Caption = tl
lblCPUTotal.Caption = t2
lblHDTotal.Caption = t3
lblDVDTotal.Caption = t4
lblRAMTotal.Caption = t5
lblCabTotal.Caption = t6
lblVDUTotal.Caption = t7
lblKybdTotal.Caption = t8
lblGrandTotal.Caption = tl +t2+ t3 + t4 + t5 + t6 + t7 + t8
End Sub
Step 3 : Run the program and test for different combinations and values of
distances and modes of transport.
Student is encouraged to add data validation code to the above program, i.e.,
if any quantity is less than O, an appropriate error message should be displayed
and user should be made to enter correct value (quantity ,= O).
Prac'tiqls ,"t"t" 241
PRACTICAL 19
Write a program to accept a number in a text box and print its table in the
label in a form
tx4=4
2x4=8,andsoon
Solution:
Step I : Design the form as shown in Fig. P. 19.1 below :
lblTable
cmdClear
EE. P. r9.1
N = Val(txtNum.Text)
lf N >= l Then
lblHdg.Caption = "Table of " + txtNum.Text
ForI=1To10
P=N*I
lblTable.Caption = lblTable.Caption + Str(I) 1 "x" +
-
Str(N) +'-'+ Str(P) + vbCrlf * " "
Next I
Else
MsgBox "Please enter a number between 1 and 100"
txtNum.Text = ""
lblHdg.Caption = ""
txtNum.SetFocus
End If
End Sub
Step 3 : Run the program and veriff the output
Practicals t't'n" 243
PRACTICAL 20
Design a form with two option buttons (Factorial and Sum of Squares). One
text box will be used to enter a number. Write two functions - one for calculating
the factorial of a number and the other to calculate the sum of squares from one
to the number entered. On click of a command button, call the appropriate
function and display the result in a label.
Solutlon:
Step 1 : Design the form as shown in Fig. P.2O.1 below :
r Furrrrl llltaltrl
brtNum
fraCalc
optFact
optSumSq
lblRes
cmdClear
Fig. P.2O.1
N = Va1(txtNum.Text)
txtNum.SetFocus
End Sub
factorial = 1
ForI=lToN
factorial = factorial * I
Next I
End Function
sumsqrs = O
ForI=1ToN
sumsqrs=sumsqrs+I*I
Next I
End Function
t't't''
Viua tt't'l,' 245
1. What is GUI?
Ans. : GUI stands for Graphical User Interface - that is, the way a user interacts
with the computer.
2. What is the full form of the abbreviation IDE?
Ans. : IDE stands for Integrated Development Environment.
3. What is a procedural programming language? Give one example.
Ans. : In a procedural programming language the program specifies the exact
sequence of all operations. The sequence in which instructions will be
executed depends on the program logic. Example: C
4. What is an object-oriented programming language? Give one example.
Ans. : 6++, C#, Java and Visual Basic are object-oriented languages and they
use the concepts of object-oriented programming (OOP). An object can be
thought of as a collection of data and methods or functions that can
operate on that data.
5. What is an event-driven programming language? Give one example.
Ans. : In event-driven programming languages, programs do not follow a
sequential logic. The sequence of execution is controlled by the user.
Example: Visual Basic.
6. What is a high-level language?
Ans. : Programming languages such as Visual Basic, Java, C, C++, etc are called
high-level languages.
7. Name the different file types in Visual Basic along with their filename
extensions.
Ans. : Different file types in Visual Basic are: Project file (extension .VBP), Form
file (extension .FRM), Standard code module (extension .BAS), Custom
Controls (extension .OCX), a file containing information about each
project (extension .VBW)
8. What is an object?
Ans. : An object is an entity or a thing. Al1 the user interface elements such as
command button, text box, check button, option button, window, etc are
objects in Visual Basic. An object can be thought of as a collection of data
and methods or functions that can operate on that data.
9. What is a property?
Ans. : A property tells us something about an object. Just as a book has
properties such as number of pages, length, breadth, type of cover,
edition, etc., similarly, all objects in Visual Basic have properties.
246 jt'r'1l" Computer Systems and Applications - T-Y-B.Com-(Sem. VI)
61. Which function ls used to convett all upper case letten ln a string to
lower case letters?
Ans. : The LCasefl function converts all upper case letters in a string to lower
case.
62. Which function is used to remove leadlng bla'nk spaees froa a string?
Ans. : The LTrim function is used to remove leading blank spaces from a string.
63. Whtch function ls used to remove tralllng blank rpaces from a strlng?
Ans. : The RTrim function is used to remove trailing blank spaces from a string.
64. Illhtch functlon ls used to remove both leading as well as tralllng blaak
spaces from a string?
Ans. : The Trim function is used to remove leading and trailing blank spaces
from a string.
65. What ls the purposc of the Tab function la Vlsual Baslc?
Ans. : The Tab function is used to print in a specified column.
Viua t''.l,, 25L
t"r'n"
Model Paper r??' 2s5
Model Paper
1. A. Attempt eny tuto sub-questlons from a, b, c in Visual Basic
(Tnre/Falsef l2l
a) All variables must be compulsorily declared in a Visual Basic program.
b) A declaration statement begins with tJ:e keyword Dim.
c) More than one variable can be declared in a single declaration statement.
B. Attempt any turo sub-questions from d, e, f in MS-Excel (Multiple
Cholce| l2l
d) When you are typing a formula in a cell. The first thing that must be
entered is :
i) the first cell
referenced. ii| quotation marks.
ii) parenthesis. iv) an Equal sign.
e) Excel templates have the file name extension
i) .temp iii) .xtemp
ii) .xltx iv) .xls
0 If cell A3 contains 10 and cell A4 contains 15, then what is the return
value of the formula = AND(A3 > 9, A4 < 2O)?
0 TRUE iii) 2s
ii) FALSE iv) -5
C. Attempt any slx sub-questions from g, h, i, J, k, I, E, n, o in
E-Commerce (Tnre/Falsel (61
g) M-Commerce means buying and selling of goods and services using
laptop.
h) A digital signature is a digital code that is attached to a message
electronically.
i) The scope of E-Commerce is local.
j) B2C E-Commerce is between Business to Business and consumers.
k) In SSL the URL changes from HTTP to HTTPS.
l) In Public Key Encryption there is only one key called the public key.
m) In Symmetric key Encryption both the sender and the receiver use the
same key to encr5pt and decrypt the message.
n) B2B refers to a Business selling goods to other individuals.
o) Ubiquity in E-Commerce refers to information richness.
D. Attempt aay fitn sub-questlons from pr gr rr s, t, u, v, w in E-Commerce
(Multtple Cholcef (5)
p) The full form of SET in E-Commerce is
i) Secure Socket Layer ii) Secure Socket Locket
iii) Secure Socket Loop iv) Secure Socket Liasion
q) is a part of E-Commerce.
0 B2B ii) c2c
ii| B2C iv) All of these
r) The fulI form of P2P in E-Commerce is
i) Peer to Peer ii) Person to Person
iii) Person to Peer iv) Peer to Person
s) EDI stands for-.
i) Electronic Data Information ii) Electronic Data Internet
iii) Electronic Data Interchange iv) Electronic Data Interface
256 tt'T't' Computer Syslems and Applications - T.Y.B.Com.-(Sem. W)
Write the steps to compute (i)'HRA as 2Oo/o of basic salary whenever the
basic salary is 80OO or less otherwise it is 25Vo of the basic salary. (ii) DA as
l2Oo/o of basic salary or 30000 whichever is less. (iii) Tax as LO%o of
Basic+DA+HRA
4. A. Attempt any one sub-questioa from a, b in MS-EXCEL
a) A Company makes three products Bats, Racquets and Footballs whose
sale p'rice is ( 300, < 200 and ( 150 respectively. For the company to
break even, it has to achieve a total sale of < 500000 in a year. Write the
steps to find Using Solver the number of units of each of these three
products that should be sold in order to meet the desired target sale. (81
b) The following data has been entered in a worksheet (81
A B C D
1 CNO NAME PHONE BALANCE
2 4 KAPOOR 23893452 60000
3 101 DIPALI 24725467 20500
4 tt2 KULKARNI 23872569 25000
5 88 SHAMBHAVI 23891045 38000
6 49 RAJA 23800123 31500
7 54 CLERA 26598621 46830
Excess 3Oo/o
Write the steps to compute AVERAGE MARKS and grade in column F and G
as per the following criteria
Average Grade
>=60 FIRST CI"ASS
<60 but >=45 SECOND CLASS
<45 but >=35 PASS CLASS
<35 FAIL
l''l,?"
Mum. Uniu. QuestianPapers (Sem. -W (M.,2016) t t"t, 259
Write the steps to obtain the average Marks and Grade in column F and G
respectively as per the following criteria.
Average Marks Grade
70 or more A
50 or more but less than 7O B
Less than 5O C
b) Consider the worksheet
A B C
1 Invoice No. Sales Amt Commission
2 158 65000
3 r69 45000
4. t70 32000
5. r82 15000
6. 190 55000
Write steps to calculate Commission in column C using the following Policy
Salea Amount Rate of Commission
First { 15,OOO 3o/o
Next { 25,000 5o/o
Excess 8o/o
B. Answer any one sub-question from c and d in MS-EXCEL. l7l
c) The following table shows Roll no., Name and Total marks in three tests.
A B C D E F G
1 R.No. Name Accounts MHRM Export Total Result
2 2LO Sonu 55 43 61
3 202 Pinky 80 65 63
4 203 Deep 40 50 45
5 201 Minaz 42 54 69
6 205 Sophie 70 65 80
Write steps to
i) Compute Total marks in column F
-W pct., 2016)
Mum. Uniu. Question Papers (Sem. t,'t't' 261
iil Find the result in Column G, where result is "Pass" when Total marks are
l2O or more otherwise "Fail".
iiil Find number of students whose total marks are above 165 in cell F8.
The worksheet contains the Grades of various
A B c D E F G H I J
1 Emp.No. Grade HRA Bonus Grade I II III IV
2 L24 I HRA 5000 3500 1500 750
3 345 il Bonus 10000 8000 5000 3000
4 44t IV
5 528 III
6 667 II
7 801 I
Write the steps to lind the HRA and Bonus.in column C and D respectively uqing
HLOOKUP function. Potcy table to be referred for finding the HRA and Bonus is
given in the range Gl : J3
Explain steps to create Best and Worst Scenario by changing the values of
cells El2 To 87.
For Best Scenario change 83 to 5,000, B4 to 18,000, E}5 to 4,000.
For Worst Scenario change B2 to 8O,OO0, E}3 to 9,000, E}6 to 1O,O0O and then
display the summaqr
262 I"t?' Computer Syslems and Applicatbns - T.Y.B.Com.-(Sem. VI)
t,'t'r'
Question Paper tr#n' 263
QUESTION PAPER
(APRTL - 2OL
Total Marks : 75 Time elowed : Zj
Note : AIl questlons are compulsoty.
\
266 ar.11Pjro Computer Sgstems and Applications - T.Y.B.Com.-(Sem. VI)
December -2017
TimeAllowed:2% Hours Total Marks : 75
1.A. Attempt any two sub-question from (a), (b) and (c) in MS-EXCEL (True of False) (2t
a) Worksheets can be linked with each other only if they are in different workbook.
b) The legend on a chart can be removed.
c) Solver and goal seek are used for the same purpose in Excel.
B. Attempt any two sub-question from (d) (e), (0 in VISUAL BASIC (Multiple Choice) (2)
d) _ is an event driven language.
A.C B.C+
C. BASIC D. VISUAL BASIC
e) The standard prefix for Command button is
A. comd B. cmd
C. com D. cbo
0 is a part of Visual Basic IDE.
A. Code window B. Properties window
-C. Project Explorrer window D. All of the above.
C. Attempt any six sub-questions from (g), (h), (i), CI), (m), (n), (o) in E-Commerce. (True or False)
(6)
g) In the subscription model a fee is charged to the user for having access to material on the website.
h) E-Market, EDI and Interest are parts of E-Commerce.
i) The volume of B2B transactions being done is more than B2C transactions.
j) Banners and sponsorships are examples ofsubscription revenue model.
k) Authenticity refers to the ability to determine the orgin of the message received over the intemet.
1) Encryption covers all the security issues.
m) Digital signature changes for every document.
n) In SSL the URL changes to HTTPs from HTTP.
o) Digital cash is the electronic parallel of notes and coins.
D. Attempt any five sub-question from (p), (q), (r), (s)' (t) (u) (v) (w) in E- Commerce. (Multiple
Choice) (5)
p) segment of E--commerce focuses consumers dealing with each other.
a) B2B b) C2B
-c) C2C d) B2C
q) Buying and selling products on the internet is called --.
a) EDI b) E-Commerce
c) E-Business d) E-market
r) E-trailer model is revenue model.
a) Sales b) SubcriPtion
c) Advertising - d) Affiliate
s) The sender and receiver will have the same key in Key encryption'
a) Symmetric b) AsYmmetric
c) Public d) Private
-
0 means converting cipher text to plain text.
a) Encryption b) DecryPtion
c)
- Conversion d) De-conversion
u) The full form of WAP in E-Commerce is Wireless Protocol'
a) And b) APP
c) Application d) Area-
I
268 3ioat'tf Computer Systems and Applications- T.Y.B.Com-(Sem. VI)
v) Ebay.com is _
a) onlyB2B b)
onlY C2C
c) onlyB2C d)
both B2B and B2C
w) When you make a payment using PayPal, you have to e-mail the payment to merchant's
account.
a) Current b) Saving -
c) PayPal d) None ofthese
2.A. Answer any one sub-question from (a) and (b) in E- Commerce. (8)
a) Explain the features of E-Commerce.
b) Explain the following B2C models in E-Commerce.
i) E-Tailer iD Content Provider
iii) Tansaction Broker iv) Market Creator
B. Answer any one sub-question from (c) and (d) in E-Commerce. (7)
c)
Discuss the various security issues in E-Commerce
d)
Explain how an Online Credit Card Transaction Works?
3.A. Answer any one sub-question from (a) and (b) in MS-EXCEL. (8)
Consider the worksheet
A B C D E
I NAME CITY SALES COMMISSION BONUS
2. RAHUL MUMBAI 80000
J ANJALI PUNE 100000
4. POOJA BANGLORE 50000
5. RAJ HYDERBAD 95000
6. KAJOL PLINE 200000
7. ADITYA BANGLORE 300000
8. SEEMA HYDERBAD 40000
Write Steps to perform the following:
i) To compute Commission @8% of sales whenever sales are below.
75,000 otherwise @ l0% of Sales in column D.
ii) To compute the Bonus as 2o/o of the Sales for Sales up to { 50,000 otherwise @ 5% of Sales in
column E.
The data has been entered in a worksheet.
A B C D E F G
l. NAME TESTl TEST2 TEST3 TEST4 AVERAGE GRADE
MARKS
2 SAMIRA 66 77 70 70
J SAIRA 56 67 72 77
4. NASIR 45 54 55 60
5 NITIN 40 45 48 56
6 SARITA 67 78 80 85
7 ADIL 65 66 69 78
Where Testl, Test2, Test3 and Test 4 are marks scored by the candidates in 4 tests.
Write steps to :
3.B. Answer any one sub-question from (c) and (d) in MS-EXCEL. (7)
c) The data has been entered in a worksheet.
A B C D E F G H
I NAME DESIGNATION HRA DA DESIGNATION HRA DA
2. SONU PEON PEON 4000 5000
J. PINKY CLERK CLERK 8000 10000
4. RINKU CLERK MANAGER 15000 20000
5. SOPHIE MANAGER
6. PREM PEON
,l
BINDU CLERK
8. TINA MANAGER
Write steps to find the HRA and DA in column C and D respectively using VLOOKUP function. Policy
table to be referred for finding the HRA and DA is given in the range F2:H4.
Consider the worksheet
A B C D
1 NAME MONTHLY SALARY ANNUAL INCOME INCOME TAX
2. RAHUL 80000
J ANJALI 100000
4. POOJA 50000
5 RAJ 65000
6. KAJOL 40000
7 ADITYA 125000
8. SEEMA 40000
Write steps to calculate Annual Income in column C and Income Tax in column D where Income -Tax
is calcaluted as follows.
Taxable Annual Income Rate
First 1,00,000 Nil
Next 2,00,000 t0%
Excess 20o/n
4.A. Answer any one sub-question from (a) and (b) in MS-EXCEL (8)
a) The following data is entered in a worksheet regarding expenses (in {) during January, Feburary,
March and
A B C D E
1 ITEM JAN FEB MARCH APRIL
2. EDUCATION 6000 6000 6000 6000
J FOOD 15000 16000 17000 r 6000
4 RENT 4s000 45000 4s000 45000
5 CAR 12000 I 5000 I 3000 14000
6. TOTAL
Write steps to do the following :-
i) Find the total expenses in each month in the cells B6, C6, D6 and E6.
ii) Create 3-D Bar chart for expenses of January, February, March and April.
iii) Create a Pie chart for the month of March.
iv). Create a Line diagram for the months Febuary and April.
b) The following table shows Quantity, Unit Price, Income and total Income of a shopkeeper who sells
rice, dal, and tea.
A B C D E
Write steps in Excel using Solver to find how much quanlty of rice, dal, sugar and tea should be sold in
order to achieve total income of '50,000, assuming that quanity should be integer only.
4.B. Answer any one sub-question from (c), (d) in MS-EXCEL. (7)
c) The data has been entered in a worksheet.
A B C D
I EMPNO NAME SALARY INCOME TAX
2. E00l DOLLY 35000
3. E002 ANJALI 55000
4. E003 DIPALI 42000
5. E004 RAJ 50000
6. E005 KAJOL 52000
7 E006 ADITYA 75000
8. E007 REEMA 60000
Write steps to do the following :-
i) Display only those rows where the Salary is more than { 50,000.
iD Display only those rows where the Salary is more than ( 45000 but less than { 65,000.
iii) Display only those rows where name do not start with "M".
d) Explain the.following functions in MS-EXCEL.
l. ToDAY0 2. COTNTBLANKo
3. SMALL 0 4. YEAR 0
s. coRREL0 6. WEEKDAY0
7. DAY0
5.A. Answer any one sub-question from (a) and (b) tn VISUAL BASIC. (8)
a) Write a project in VB to accept students name and marts in Accounts, Economics and MHRM.
Calculate and display total mark and percentage.
b) Write a project in VB to design a suitable form which allows a user to enter three number in text
boxes. Find and display tle maximum number among them.
5.B. Answer any one subquestion from (c) and (d) in VISUAL BASIC. (7)
c) Write a project to design a suitable form to allow the user to enter name of salesperson and the total
sales. Calculate and display tlre commission earned by the salesperson based on the following table.
Use controls.
Total Sales (() Commission
Less than or equal to 90,000 Nil
Between 90,000 and up to 1,50,000 t0%
More than 1,50,000 t2%
d) Write a project in VB to compute and display the sum of the series 2 +5 +8+ 11+ ...+ 32.
ffli
Mumbai University Question Paper. (March 2018) flrlf 271
1.A. Attempt any two sub-questions from (a), (b) and (c) in MS-EXCEL. (True or False) {2)
a) The size ofchart can be changed.
b) A template has the file name extension .XLTX.
c) A workbook can contain maximum three worksheets.
B. Attempt any two sub-questions from (d), (e) and (f) in VISUAL BASIC. (Multiple Choice) (2)
d) In a VB project, the form design is carried out in the
l. properties 2. Tools Box
3. Project Explorer 4. Form Window
e) Visual Basic controls are _.
l. code 2. Part ofmenus
3. rules 4. Objects
0 is a valid object name for a text box.
l. TxtClass 2. Txt Class
3. Txt+class 4. TextClass
C. Attempt any six sub-questions from (g), (h), (i), (i), (k), (t), (m), (n), (o) in E-Commerce. (True or
False) (6)
g) Traditional commerce is more reliable than E-Commerce.
h) Non-repudiation refers to non-denial of E-Commerce transactions.
i) Portals eam revenue from advertising and referral fees.
j) Encryption is a process of converting cipher text to plain text.
k) Intergrity in E-Commerce ensures that data is not altered during transmission.
D In E-Commerce only credit cards can be used for making payments.
m) In public Key encryption there is only one key.
n) Hacking of credit cards and password is possible in E-Commerce.
o) Digital cash is the electronic parallel of notes and coins.
D. Attempt any live sub-questions from (p), (q), (r), (s), (t), (u), (v) (w), in E-Commerce. (Multiple
Choice) (6)
p) A Computer to Computer exchange of business transaction is called
A. E-Buisness B. Super Market
C. EDI D. E-Market
q) In _ E-Commerce the consumers deals with each other.
A. C2C B. B2C
C. B2B D. C2B
r) It is convention that all sites ihat uses SSL connection while making a secure connection use
instead of HTTP.
A. SMTP B. HTTPS -
B. FTP D. TCP/IP
s) The most commonly used form of payment in E-Commerce is _..
A. Credit Card B. PayPal
C. Petro Card D. Digital Cash
t) In online stored value systems, cards that have embedded chips that store personal information is
called _.
A. Debit Card B. Smart Card
C. Credit Card D. Ideal card
u) The full form of WAP in E-Commerce is Wireless _ Protocol.
A. And B. App
C. Application D. Area
272 tr"9"r' Computer Systems and Applications- T.Y.B.Com.-(Sem. VI)
5 SUGAR 2 HAMAM 25
6. PEARS 5 DETTOL 35
7 NESCAFE 6 LIRIL 40
8. KITKAT 20
9 NESCAFE 78
10. TEA 110
ll SUGAR 60
12. I
oIL 125
Write steps to find the Price in column C using VLOOKUP function. Table to be refened for finding
.he Price per unit is given in the range F2:G12. Also find Cost in Column D. (Total Cost: Price* Quanity)
Consider the worksheet.
A B C D E F
I ROLL NO. TESTI TEST2 TEST3 AVERAGE RESULT
2 1^44 56 49 55
J 454 76 87 65
4. A58 74 70 70
5 A60 87 54 67
6. AI 35 40 36
Write steps to
i) Calculate Average marks in column E.
ii) Find the result in Column F, where result is "Pass" when Average marks are 40 or
more otherwise "Fail".
iii) Find number of students whose Average marks are more than or equal to 70 in cell E8.
\. Answer any one sub-question from (a) and (b) in MS-EXCEL. (8)
a) The following data is entered in a worksheet regarding the stocks during January, February and
March.
A B C D E
I ITEM JAN FEB MAR TOTAL
2. PENCIL 4000 4200 4500
3. PEN 3000 3000 3100
4. NOTE BOOK 2000 I 800 1800
5. WRITING PAD 1000 l 100 1200
Write steps to
i) Find the total stock of each product in the cells E2,F.3, E4 and E5.
ii) Create 3-D Bar chart for the data.
iii) Create a Pie chart for the month of March.
iv) Create a Line diagram for Jan and March.
b) The following table shows Quantity, Cost Price per unit (CPRICE) and Selling Price per unit
A B C D E F G
1 PRODUCT QTY CPRICE SPRICE COST SALES PROFIT
2. PRODUCT I 200 100 t23
J PRODUCT 2 240 75 r20
4. PRODUCT 3 430 28 60
5. PRODUCT 4 t20 45 70
6. PRODUCT 5 320 40 55
7 PRODUCT 6 230 50 65
8 PRODUCT 7 250 65 80
Write steps in Excel to calculate Cost in column E, Sales in column F, Profit in column G and Total
rofit in G9 respectively. Write steps in Excel using Solver to find what the cost per unit should be in order to
;hieve the Total Profit of 75,000.
'coST=QTY'ICPzuCE
274 fdt/ Computer Systems and Applications- T.Y.B.Com.-(Sem.
toLg5=QTY*SPNCE
PROFIT=SALES-COST)
4.B. Answer any one sub-question from (c) and (d) in MS-EXCEL.
The data has been entered in a worksheet.
A B C D
I sNo NAME CITY SALESAMOUNT
2. s00l AJAY MUMBAI 3s000
J. s002 POOJA PUNE 55000
4. s003 AJIT MUMBAI 42000
5. s004 JAY BANGALORE s0000
6. s005 RITA PUNE 52000
7 s006 SAMIR MUMBAI 75000
8. s007 NEHA BANGALORE 60000
Write steps to do the following :-
D Display only those rows where the City is Bangalore'.
iD Display only those rows where Sales Amount is below average Sales Amount.
iii) Display only those rows where the Sales Amount is more than 48,000 but less than 70,000.
d) Explain the following functions in MS-EXCEL.
r. DATE0 2. COLTNTBLANKO
3. LARGE0 4. NOWo
5. SMALL 0 6. MONTH 0
7. WEEKDAYO
5.A. Answer any one sub-question from (a) and (b) in VISUAL BASIC.
a) Write a project in VB to design a suitable form which allows the user to enter a number i
calculate and display whether the number is divisible by 7 or not.
b) Write a project in VB to design a suitable form which allows the user to enter Name and i
Salary and calculate Bonus as 45% of Basic Salary whenever basic salary is less than 25
otherwise 40% of Basic Salary using a'Calculate button and display the result.
5.B. Answer any one sub-question from (c) and (d) in YISUAL BASIC
c) Write a project in VB to design a suitable form which allows the user to enter length of a side ,
square and then calculate and display area and perimeter ofthe square.
(Area=Side*Side)
Perimeter4*Side)
d) Write a project in VB to design a suitable form which allows the user to enter an integer a
calculate and display the factorial of that integer when the "Calculate" button is clicked.
(Factorial of N+l *2*3*............*N)
rfrff
r\q?''\q9
Yffit&\
0ur Outstanding Puhlications for
T.Y.B.Gom. Semester' Vl
DISCIPLINE RELATED ELECTM (DRE) COURSES
HUMAN RESOURSE IJIANAGEMENT (Commerce-Vl)
A1aga,:t'V.a, o?'..2'
OBJECTIVE QUESTION FOR HUMAN RESOURSE MANAGEMENT
Ajagaonkar Patxar
BUSINESS ECONOMICS
Kalkoti. Rajalaksnm,;
BUSINESS ECONOMICS
Ivlithani Sayyeo
tqifr 3rrft gq6ul
rsi'r, qra-ror, sr}6q
.or.rerkO Oefqrrg
3{rqrd-fi-{
DrscpLrNE spEcIFIc ELECTM COURSE (DSE1 '..
FINANC|AL ACCOUNTlNG
i)hopde & others
COST ACCOUNTING
l''.tde & others
MANAGEMENT & ORGANTSATTON DEVELOPMENT (8,M.-t)
f{qurq svt}crc
lTa{fi{
qasrq laqr
?srd, q1w
ABI LITY E NHANCEMENT COURSES €ffi} n
DIRECT AND INDIRECT TAXATION - (Paper.ll} GST
Singavi & others
EXPORT MARKETING
Joshi
COMPUTER SYSTEM & APPLICATIONS
Gadiwalla. Tekwani
MARKETING RESEARCH .1I
Nerurkar. Joshi. Kalkoti. Tripathi. Dalvi
Mo frqurc
it"
PVT. tTD.
ISBN - 978-E1-936595-s_7
unit N0.4. Ground Floor Lalwani lndustrial Estate. i4.G.D. Ambekar Marg, wadala. Mumbai.400 03
rel.:Jc22i 6662 45s3. 6662 4554. Fax: 6662 4556. e.mairr [email protected]
ill]illtffiililIilI]lIilt
Follow ur, /sherhpuhtishers
ffi ffi trr,.il,.pubtishers
Price - { 220.00