Professional Documents
Culture Documents
TECHNOLOGY TRAINING
Board of Studies
The Institute of Chartered Accountants of India
The objective of this supplementary study material is to provide uniform reference
material to the students undergoing the 100 hours Information Technoloy Training
Programme.
All care has been taken to provide the material in a manner useful to the students.
However the material has not been specifically discussed by the Council of the
institute or any of its Committees and the views expressed herein may not be
taken to necessarily represent the views of the Council or any of its Committees.
In case students have any suggestions to make for future improvement of the
material contained herein, they may write to Board of Studies, C-1, Sector –1,
NOIDA.
In the new scheme of Education and Training, 250 Hours Compulsory Computer
Training has been replaced by 100 Hours Information Technology Training
considering progress in the computer education at the school level. The new
curriculum of 100 Hours ITT has been framed revamping the old curriculum. It
is desired that a student should undergo 100 Hours of Information Technology
Training only after undergoing three months of practical training by which they
are expected to develop knowledge about the practical application of Information
Technology in various areas of professional practice. It is also desired that students
should study the subject of Information Technology concurrently while
undergoing 100 Hours Information Technology Training so that a proper balance
between theoretical knowledge and practical application is achieved.
The Training components would focus on application softwares relevant for
accounting and auditing. In addition, knowledge of electronics spreadsheets,
data base management systems, web technology and systems security and
maintenance are strengthened. In order to provide the students with a reference
material, the Board of Studies is providing a kit comprising of 3 modules of
Compulsory Computer Training Programme and a supplementary study material.
Students are advised to study only the relevant topics of uniform background
material for 250 hours Compulsory Computer Training Programme along with
this supplementary study material. A table giving the page references of the
relevant topics of 250 hours Compulsory Computer Training Programme material
is included in this supplementary study material to facilitate the students for
easy identification.
We acknowledge with thanks the valuable contribution of Dr. Sanjeev Gupta,
Director, Greater Noida Campus, Kalinga Institute of Industrial Technology,
Deemed University, Orissa for preparing material on Visual Basic. Our special
appreciation to Mrs. Indu Arora, Joint Director of Studies for her contribution in
compiling, editing and consolidating this supplementary study material.
We hope that this background material would help in bringing about the
uniformity in approach by the various accredited institutions imparting this
education programme to our students.
CONTENTS
Topic Pages
Unit -1 : Introducion 13
Unit - 6 : VB Functions 44
Unit - 7 : Arrays 49
1 DATA EXTRACTION
A
P
T AND DATA ANALYSIS
E
R
Introduction
In this chapter, we look at how different tools can be used for data extraction. The
basic assumption is that the data are stored in databases. Most of the tools described
in this chapter depend on ODBC (Open Database Connectivity). ODBC is a
programming interface that enables applications to access data in Database
Management Systems that use Structured Query Language as a Data access
standard. Each database program, such as Access or dBASE, or database
management system, such as SQL Server, requires a different driver(a program
file used to connect to a particular database).
Microsoft Excel
Excel (version 9 and above) can work with external databases in three different ways.
z Excel can import data from databases and flat files. Flat file are text files,
which store information in a comma or tab delimited format.
z Excel can retrieve data with Microsoft Query.
z Excel can import data with Visual Basic for Applications (VBA).
Importing data from databases and files
Excel can import data from most data sources by using the command Data-> Import
External Data-> Import Data and then choosing the required data in the Select
Data Source dialog box :
The Data Connection Wizard, available when the user right-clicks New Source
in the Select Data Source dialog box, makes it possible to import data from external
data connections not available from the Select Data Source dialog box. These
sources may include OLE (Object Linking and Embedding) DB(Database) data
sources and any data sources a system administrator supplies.
Retrieve data with Microsoft Query
Microsoft Query is a simple front-end, used when the auditor needs to perform
specialized query tasks such as the following:
z Filter rows or columns of data before they are brought into Excel.
z Sort data before it is brought into Excel.
z Join multiple tables
The auditor can use Query to set up ODBC(Open Database Connectivity) data
sources to retrieve data. In Query, one can use the Query Wizard to create a
simple query, or one can use advanced criteria in Query to create a more complex
query.
Importing data with VBA
One can use a Visual Basic for Applications (VBA) macro to gain access to an
external data source. Depending on the data source, we can use either ActiveX
Data Objects or Data Access Objects to retrieve data using VBA. VBA is a
application specific subset of the Visual Basic.
Using IDEA as an Audit Tool
IDEA (Interactive Data Extraction and Analysis) is a popular audit tool, sold by
CaseWare International Inc. In this section, we shall briefly see how data is
imported into IDEA and some of the features of IDEA. Below is an overview of
IDEA’s GUI.
Figure : IDEA’s Interface
Database Toolbar
Start IDEA and Select a Working Folder and Enter Client Information
z To set the working folder select the following menu command: FILE -> Set
Working Folder. Alternatively, click the “Change working folder from”
button on the File Explorer’toolb.~r. The “Browse for Folder” dialog will
appear. Navigate to and select the following folder:
C:\Program Files\IDEA\Tutorial
Note: This assumes IDEA has been installed in the default installation folder on
the C drive. If not, select the appropriate folder.
z Click the OK button. The Client Properties dialog appears. Enter the Client
name and period of audit. The client properties will be stored in a file called
Client.inf in the working folder. Once a working folder is set, this will remain
the default until changed.
Import the Data
z Point to the “Import Assistant” button on the Operations toolbar and click
this button. The Import Assistant dialog will be displayed.
z Select a data file to import by clicking on the Select File button on the toolbar
and then navigate to and select the following file(for example):
C:\Program Files\lDEA\Tutorial\Master.xls and click the “Open” button.
z Note the five different import methods. Accept the default method, Le.
z New files and standard PC formats” and click “Next”.
z The Import Assistant file type step will be displayed with the “Microsoft
Excel” option correctly selected. Click “Nexf”.
z The Import Assistant will display a list df any worksheets and tables defined
within the selected workbook. Select Sheet1 $ (the first and in this example
the only worksheet). Click “Next”. Note that it is possible to import multiple
worksheets and/or tables at One time. Each workSheet or table will be
imported into a separate database.
z The Import Assistant’s “Change length of character fields” step dialog will
be displayed, warning that all character fields will be imported with a length
of 255 characters unless changed. This is not likely to be the underlying
character field length. Therefore, check the box to Determine the maximum
field length and accept the default to scan 100 records to determine this
length. Click “Next”.
z The final step of the Import Assistant will ask the user to change or confirm
details about the imported database. Select or confirm the option to
“Generate field statistics” on import. This is checked by default. This is
recommended and will be used to reconcile the data back to the host system.
There is also an option to name the database. The option to Import (rather
than Link) the data is selected by default. It is not possible to link to_a MS
Excel worksheet.
Summary
Thus we have seen the ways by which data stored in databases can be imported
into the most widely used CAAT tools. In the next section we shall look at some
of the techniques that may be used for Data Analysis.
Data Analysis
Introduction
In this section, we shall see some illustrative examples of how the data imported
into Excel, ACL and IDEA can be analysed by an auditor.
Auditing with Excel
Having imported the required information into Excel, the auditor can then use
the various features of Excel to assist him in audit. For example, the auditor can
z Sort the data and search for missing or duplicate data, for example missing
cheque number or duplicate invoice number..
z Highlight or extract significant information, like cash expenses over
Rs.20,OOO.
z Calculate statistics on numeric fields and use this information to carry out
sampling tests.
z Information on using functions and macros in Excel has already been covered
in one of the earlier chapters.
Example
In this’ example, we shall see how, Excel(version 9 and above) can be used to select
a random sample.
1 First import the data as outlined in the earlier chapter.
2 Next Click on Tools-> Data Analysis as shown below. If the Data Analysis
command is not available, you need to load the Analysis ToolPak add-in
program. To load the Analysis ToolPak click Tools -> Add-Ins and make sure
that “Analysis ToolPak” is selected.
Excel’s Data
Analysis
Command
3 Choose “Sampling” from the list of Analysis Tools. At this point the dialog
box shown below should open up.
4 Now we need to specify the Input Range, which should contain numeric data.
In this example, the Column A is a numeric field and we shall specify it as the
Input Range and then enter the number of sample items required. It may be
noted that the number of samples required are calculated as per the formula
given in the earlier chapter. Click OK, when finished.
Mechanical Accuracy
One of the first things IDEA should be used for is to total the file and prove the
accuracy of any calculations. Totalling the file is performed by using the field
statistics function (available on File Import). Calculations can be checked either
by adding a calculated field using the Field Manipulation option to create a
calculation of the item or by an exception test of mis-calculations using the
extraction functions.
The accuracy of any management report may involve a wider use of functions to
achieve the result of reproducing the report. In these cases a series of joins and/or
summarizations, or the aging function in the case of aged debt analyses, may be
necessary.
Analytical Review
IDEA can help with the preparation of figures for an analytical review. In particular,
it can generate analyses which would not otherwise be available. The File
Stratification function (from the Analysis menu) will give a profile of the population
in value bands, groups of codes or dates. This is particularly useful when auditing
assets such as debtors, inventories, loans or for a breakdown of transactions.
Additionally, the information can be Summarized by particular codes or sub-codes.
Figures can also be compared against previous years to determine trends. If
graphical analysis is required, the “Chart Data” command on the Data menu or
graph option within the Results View can be used.
Validity (Exception Testing, Compares and Duplicates)
Exception testing can be used to identify unusual or strange items. These may be
simply large items or where the relationship between two pieces of information on
an item does not correlate (e.g. rate of pay and pay grade). Many fields of information
can also be checked for allowable values (e.g. standard fees).
Statistical sampling is commonly used to test for validity in a manner which then
allows for evaluation across a population. The more sophisticated methods such
as Monetary Unit Sampling are difficult to implement manually. Wherever tests
need to refer to physical documentation or assets rather than computer records
then an appropriate statistical sampling technique should be used.
Duplicates testing can be very effective in certain circumstances such as testing
payments or looking for double input of inventory tags during inventory counts.
It may be necessary to join two files together first to perform a validity test e.g.
transaction file to a master file.
Completeness (Gaps and Matches)
The Gap Detection options (Numeric, Character and Date) can be used to test for
completeness. There must be a sequential number on source documentation for
this to work. Inventory and sales files can be tested for completeness of despatch
note numbers and purchases files for received numbers. It may also be appropriate
8 INFORMATION TECHNOLOGY TRAINING
DATA EXTRACTION AND DATA ANALYSIS
to test for gaps on a series of cheque numbers and also for completeness of inventory
tags or bin card numbers. Another effective test for completeness is to cross-check
between a master file (e.g. of maintenance contracts) and transactions (e.g. invoices)
to see if there are any items on the master file for which a transaction has not been
raised.
Cut-off
Year end ledger, inventory files or transaction files can be tested for cut-off by
testing for items with dates or sequence numbers above or below the year end cut
off. This is to ensure that the data has been provided is for the correct audit period.
Example
In this example, we shall look at how IDEA can be used to identify exceptional or
unusual transactions. Let us suppose that an auditor wishes to examine all sales
transactions that took place on a Sunday. The file we shall use for the purpose of
this example is “Customer Invoices File.imd” located in the samples folder.
1 First start IDEA. It is possible that that File .Explorer window already shows
“Customer Invoices file”. If so, double click it. If the file is not already open,
use File-> Open, then navigate to the samples folder and open it.
2 Click on Data-> Extractions... This should open the Extract to File(s) dialog
box. Double click the default file name (EXTRACTION1) to change it and
enter “Sunday Sales”. Please see the figure below.
3 Now enter the “Equation Editor” by clicking the Button as shown in the
previous figure. The Equation Editor Dialog Box should open. The “Equation
Editor” allows the user to enter various criteria.
Figure 1-1
The Visual Basic tool bar functions like the tool bar in any other Microsoft
application. It provides shortcuts for many of the common operating commands.
It also shows you the dimensions and location of the form currently being designed.
(b) The tool box
Figure 1.2
The tool box gives you access to the controls that you use on a form.
A control is an object such as a button, label or grid. Each control appears as a
Figure 1.3
button in the tool box. If the control you are looking for is not in the toolbox, select
Components from the Project menu.
(c) The form designer window
This window is where you design the forms that make up your user interface.
Figure 1.5
Figure 2.1
If the New Project box appears, select Standard.EXE, and then click Open.
Normally, a default form Form1 will be available for you to start your new project.
Now, double click on Form1, the source code window for Form1 as shown in
figure 2.2 will appear. The top of the source code window consists of a list of
objects and their associated events or procedures. In figure 2.2, the object displayed
is Form and the associated procedure is Load.
When you click on the object box, the drop-down list will display a list of objects
you have inserted into your form as shown in figure 2.3.
You can also perform simple arithmetic calculations as shown in Example (b).
VB uses * to denote the multiplication operator and / to denote the division
operator. The output is shown in figure 2.6, where the results are arranged
vertically.
Example (b)
Private Sub Form_Activate ( )
Print 20 + 10
Print 20 - 10
Print 20 * 10
Print 20 / 10
End Sub
Example (b) can also be written as
Private Sub Form_Activate ( )
Print 20 + 10, 20 – 10, 20 *
10, 20 / 10
End Sub
The numbers will be arranged
in a horizontal line separated by
spaces as shown in figure 2.7.
Example (c) is an improved
version of Example (b) as it
employs two variables x and y
and assigns initial values of 20
and 10 to them respectively.
When you need to change the
values of x and y, just change the
Figure 2.7 : Output in horizontal line
initial values rather than changing every individual value which is more time
consuming.
Example (c)
Private Sub Form_Activate ( )
x = 20
y = 10
Print x + y
Print x - y
Print x * y
Print x / y
End Sub
Besides, you can also use the + or & operator to join two or more texts (string)
together like in example (d) i and (d) ii.
Example (d) i Example (d) ii
Private Sub Form_Activate ( ) Private Sub Form_Activate()
A = “Tom” A = “Tom”
B = “likes” B = “likes”
C = “to” C = “to”
D = “eat” D = “eat”
E = “burger” E = “burger”
Print A + B + C + D + E Print A & B & C & D & E
End Sub End Sub
Figure 2.9
In the exercise that follows, you will create a single form as shown below.
The exercise shows you how to add controls to a form and how to set properties
at design time.
Designing the form
The form has three controls on it. There is a label which will display the text
“Hello” and two command buttons. A label control is used to display text. A
command button control enables the user of your application to click on a button
when they require an action to be carried out.
Drawing controls
Drawing controls is a two step process. First you need to add the control you
want by double clicking on it in the tool box. Secondly, you need to position and
Figure 2.11
Figure 2.10
the label control.
Double click on the label control button and a label will appear in the middle of
the form.
Moving controls
Controls can be moved
around a form by
dragging them with the
mouse. Move the cursor
to the label and depress
the left mouse button.
Keeping the mouse
button depressed, drag
the control to its new
location, as shown in
Figure 2-12 and now release the mouse button.
Figure 2.12
Setting properties
Once the control is positioned correctly on the form, you then need to customize
the properties of the control to suit your requirements.
This application requires you to change the text that is displayed in the label control
from the default “Label1” to “Hello”. You are
also going to change the alignment to Centre
and the font to Arial with font size 16.
Figure 2.13
and click the Font Dialog Button (…) to bring up the font window. Set the font
values to Arial, Regular, 16.
Figure 2.14
Figure 2.15
A command button control will appear in the middle of the form. Move the button
so that it is under the label. Repeat the last two steps to add a second button under
the first.
Your form should appear similar to the one
shown in figure 2-16. Select the button with
the caption Command1. Make sure you can see
the handles that indicate that the button is
selected. Using the properties window, change
the caption property to On. Use the same
process to set the caption for the bottom button
to Off. Using the properties window, change
the Name property for the form to Hello.
Now that the form is complete you can see it in action by running it.
When you have written code for the buttons, running the application will allow
you to activate the code. For now your buttons will not do anything. Click on the
start (play) button on the tool bar.
Figure 2.17
Your form will appear like a window from any other Microsoft application. Click
on the Stop button on the tool bar to return to the Visual Basic design environment
2.4 Saving your application
The last step in this chapter is to save your application so that you can use it for the
exercises later on. Click on the save button on the tool bar.
Figure 2.18
Visual Basic first asks you to save the form and then the project file. Remember
that each represents a separate file. Specify the filename for the form as hello.frm.
The file extension “frm” indicates that the file is a form file.
Figure 2.19
Exercise
Q: Design the interface to calculates the volume of a cylinder.
Figure 3.1
The label is a very useful control for Visual Basic, as it is not only used to provide
instructions and guides to the users, it can also be used to display outputs. One of
its most important properties is Caption. Using the syntax label. Caption, it can
display text and numeric data. You can change its caption in the properties window
and also at runtime. Please refer to Example 3.1.1 and Figure 3.1 for the usage of
label.
The Check Box control lets the user to select or unselect an option. When the Check
Box is checked, its value is set to 1 and when it is unchecked, the value is set to 0.
You can include the statements Check1.Value=1 to mark the Check Box and
Check1.Value=0 to unmark the Check Box, and use them to initiate certain actions.
For example, the program will change the background color of the form to red
when the check box is unchecked and it will change to blue when the check box is
checked. You will learn about the conditional statement If….Then….Elesif in later
lesson. VbRed and vbBlue are color constants and BackColor is the background
color property of the form.
Example 3.8.1
Private Sub Check1_Click ()
If Check1.Value = 0 Then
Form1.BackColor = vbRed
ElseIf Check1.Value = 1 Then
Form1.BackColor = vbBlue
End If
End Sub
The Option Box control also lets the user selects one of the choices. However, two
or more Option Boxes must work together because as one of the Option Boxes is
selected, the other Option Boxes will be unselected. In fact, only one Option Box
can be selected at one time. When an option box is selected, its value is set to
“True” and when it is unselected; its value is set to “False”. In the following
example, the shape control is placed in the form together with six Option Boxes.
When the user clicks on different option boxes, different shapes will appear. The
values of the shape control are 0, 1, and 2, 3, 4, 5 which will make it appear as a
rectangle, a square, an oval shape, a rounded rectangle and a rounded square
respectively.
Example 3.9.1
The File List Box is used to display the list of files in a selected directory or folder.
When you place this control into the form and run the program, you will be able to
a list of files in a selected directory as shown in Figure 3.4
Figure 3.4
You can coordinate the Drive List Box, the Directory List Box and the File List Box
to search for the files you want. The procedure will be discussed in subequent
lessons.
There are many types of data we come across in our daily life. For example, we need
to handle data such as names, addresses, money, date, stock quotes, and statistics
etc everyday. Similarly in Visual Basic, we are also going to deal with these kinds of
data. However, to be more systematic, VB divides data into different types.
4.1 Types of Visual Basic Data
(A) Numeric Data
Numeric data are data that consist of number, which can be computed
mathematically with various standard operators such as add, minus, multiply,
divide and so on. In Visual Basic, the numeric data are divided into 7 types, they
are summarized in Table 4.1
Table 4.1: Numeric Data Types
Type Storage
Byte 1 byte
Integer 2 bytes
Long 4 bytes
Single 4 bytes
Double 8 bytes
Currency 8 bytes
Decimal 12 bytes
Boolean 2 bytes
Object 4 bytes
Variant 16 bytes
(numeric)
Variant(text) Length +
22 bytes
Table 4.3
In addition, we need to enclose string literals within two quotations and date and
time literals within two # sign. Strings can contain any characters, including
numbers. The following are few examples:
memberName=”Turban, John.”
TelNumber=”1800-900-888-777"
LastDay=#31-Dec-00#
ExpTime=#12:00 am#
4.2 Managing Variables
Variables are like mail boxes in the post office. The contents of the variables change
every now and then, just like the mail boxes. In term of VB, variables are areas allocated
by the computer memory to hold data. Like the mail boxes, each variable must be
given a name. To name a variable in Visual Basic, you have to follow a set of rules.
Operator Meaning
= Equal to
> More than
< Less Than
>= More than and equal
<= Less than and equal
<> Not Equal to
* You can also compare strings with the above operators. However, there are certain
rules to follows: Upper case letters are less than lowercase letters,
“A”<“B”<“C”<“D”.......<“Z” and number are less than letters.
5.2 Logical Operators
In addition to conditional operators, there are a few logical operators which offer
added power to the VB programs. These are shown in Table 5.2.
Table 5.2
Operator Meaning
And Both sides must be true
or One side or other must
be true
Xor One side or other must
be true but not both
Not Negates truth
The format is :
Select Case expression
Case value1
Block of one or more VB statements
Case value2
Block of one or more VB Statements
Case value3
Block of one or more VB statements
Case value4
.
.
.
Case Else
Block of one or more VB Statements
End Select
* The data type specified in expression must match that of Case values.
Example 5.1
‘ Examination Grades
Dim grade As String
Private Sub Compute_Click( )
grade=txtgrade.Text
Select Case grade
Case “A”
result.Caption=”High Distinction”
Case “A-”
result.Caption=”Distinction”
Case “B”
result.Caption=”Credit”
Case “C”
result.Caption=”Pass”
Case Else
result.Caption=”Fail”
End Select
*Please note that grade is a string, so all the case values such as “A” are of String
data type.
Example 5.2
Dim mark As Single
Private Sub Compute_Click()
’Examination Marks
mark = mrk.Text
Select Case mark
Case Is >= 85
comment.Caption = “Excellence”
Case Is >= 70
comment.Caption = “Good”
Case Is >= 60
comment.Caption = “Above Average”
Case Is >= 50
comment.Caption = “Average”
Case Else
comment.Caption = “Need to work harder”
End Select
End Sub
z Note we used the keyword Is here to impose the conditions. This is generally
used for numeric data.
Example 5.3
Example 5.2 could be rewritten as follows:
Dim mark As Single
Private Sub Compute_Click()
’Examination Marks
mark = mrk.Text
Select Case mark
Case 0 to 49
comment.Caption = “Need to work harder”
Case 50 to 59
comment.Caption = “Average”
Case 60 to 69
comment.Caption = “Above Average”
Case 70 to 84
comment.Caption = “Good”
Case Else
comment.Caption = “Excellence”
End Select
End Sub
Visual Basic allows a procedure to be repeated as many times as the processor
could support. This is generally called looping .
5.5 Do Loop
The format are
a) Do While condition
Block of one or more VB statements
Loop
b) Do
Block of one or more VB statements
Loop While condition
c) Do Until condition
Block of one or more VB statements
Loop
d) Do
Block of one or more VB statements
Functions are similar to normal procedures but the main purpose of the functions
is to accept certain inputs and pass them on to the main program to finish the
execution. There are two types of functions, the built-in functions (or internal
functions) and the functions created by the programmers.
The general format of a function is functionName(arguments)
where arguments are values that are passed on to the functions.
In this lesson, we are going to learn two very basic but useful internal functions,
i.e. the MsgBox( ) and InputBox ( ) functions.
6.1 MsgBox ( ) Function
The objective of MsgBox is to produce a pop-up message box and prompt the user
to click on a command button before he /she can continue. This message box format
is as follows:
yourMsg=MsgBox(Prompt, Style Value, Title)
The first argument, Prompt, will display the message in the message box. The
Style Value will determine what type of command buttons appear on the message
box, please refer Table 6.1 for types of command button displayed. The Title
argument will display the title of the message board.
Table 6.1: Style Values
We can use named constant in place of integers for the second argument to make
the programs more readable. In fact, VB6 will automatically shows up a list of
names constant where you can select one of them.
Example 6.1
(i) The Interface:
You draw three command buttons and a label as shown in Figure 6.1
Figure 6.1
Figure 6.2
To make the message box looks more sophisticated, you can add an icon besides
the message. There are four types of icons available in VB as shown in Table 6.3
Table 6.3
Value Named Constant Icon
16 vbCritical
32 vbQuestion
48 vbExclamation
64 vbInformation
Example 6.2
In this example, the following message box will be displayed:
Figure 6.3
You could draw the same Interface as in example 6.1 but modify the codes as
follows:
Private Sub test2_Click()
Dim testMsg2 As Integer
testMsg2 = MsgBox(“Click to Test”, vbYesNoCancel + vbExclamation, “Test
Message”)
If testMsg2 = 6 Then
display2.Caption = “Testing successful”
ElseIf testMsg2 = 7 Then
display2.Caption = “Are you sure?”
Else
display2.Caption = “Testing fail”
End If
End Sub
6.2 The InputBox( ) Function
An InputBox( ) function will display a message box where the user can enter a
value or a message in the form of text. The format is
myMessage=InputBox(Prompt, Title, default_text, x-position, y-position)
myMessage is a variant data type but typically it is declared as string, which accepts
the message input by the users. The arguments are explained as follows:
z Prompt - The message displayed normally as a question asked.
z Title - The title of the Input Box.
z default-text - The default text that appears in the input field where users can
use it as his intended input or he may change to the message he wish to key in.
z x-position and y-position - the position or the coordinates of the input box.
Example 6.3
(i) The Interface
Figure 6.4
(ii) The procedure for the OK button
Private Sub OK_Click()
Dim userMsg As String
userMsg = InputBox(“What is your message?”, “Message Entry Form”, “Enter
your messge here”, 500, 700)
If userMsg <> “” Then
message.Caption = userMsg
Else
message.Caption = “No Message”
End If
End Sub
When a user clicks the OK button, the input box as shown in Figure 6.5 will appear.
After user enters the message and clicks OK, the message will be displayed on the
caption, if he clicks Cancel, “No message” will be displayed.
Figure 6.5
By definition, an array is a list of variables, all with the same data type and name.
When we work with a single item, we only need to use one variable. However, if
we have a list of items which are of similar type to deal with, we need to declare an
array of variables instead of using a variable for each item. For example, if we
need to enter one hundred names, instead of declaring one hundred different
variables, we need to declare only one array. We differentiate each item in the
array by using subscript, the index value of each item, for example name(1),
name(2),name(3) .......etc.
Figure 7.1
(ii) The codes
Dim studentName(10) As String
Dim num As Integer
Private Sub addName()
For num = 1 To 10
studentName(num) = InputBox(“Enter the student name”, “Enter Name”,
“”,1500, 4500)
If studentName(num) <> “” Then
Form1.Print studentName(num)
Else
End
End If
Next
End Sub
Private Sub Exit_Click()
End
End Sub
Private Sub Start_Click()
Form1.Cls
addName
End Sub
The above program accepts data entry through an input box and displays the entries
in the form itself. As you can see, this program will only allow a user to enter 10
names each time he clicks on the start button.
public key of a given signer and use it to verify that signer’s signatures, they cannot
discover that signer’s private key and use it to forge digital signatures. This is
sometimes referred to as the principle of “irreversibility.”
Another fundamental process, termed a “hash function,” is used in both creating
and verifying a digital signature. A hash function is an algorithm which creates a
digital representation or “fingerprint” in the form of a “hash value” or “hash result”
of a standard length which is usually much smaller than the message but
nevertheless substantially unique to it. Any change to the message invariably
produces a different hash result when the same hash function is used. In the case
of a secure hash function, sometimes termed a “one-way hash function,” it is
computationally infeasible to derive the original message from knowledge of its
hash value. Hash functions therefore enable the software for creating digital
signatures to operate on smaller and predictable amounts of data, while still
providing robust evidentiary correlation to the original message content, thereby
efficiently providing assurance that there has been no modification of the message
since it was digitally signed.
Thus, use of digital signatures usually involves two processes, one performed by
the signer and the other by the receiver of the digital signature:
z Digital signature creation uses a hash result derived from and unique to both
the signed message and a given private key. For the hash result to be secure,
there must be only a negligible possibility that the same digital signature
could be created by the combination of any other message or private key.
z Digital signature verification is the process of checking the digital signature
by reference to the original message and a given public key, thereby
determining whether the digital signature was created for that same message
using the private key that corresponds to the referenced public key.
To sign a document or any other item of information, the signer first delimits
precisely the borders of what is to be signed. The delimited information to be
signed is termed the “message” in these chapter. Then a hash function in the signer’s
software computes a hash result unique (for all practical purposes) to the message.
The signer’s software then transforms the hash result into a digital signature using
the signer’s private key. The resulting digital signature is thus unique to both the
message and the private key used to create it.
Typically, a digital signature (a digitally signed hash result of the message) is
attached to its message and stored or transmitted with its message. However, it
may also be sent or stored as a separate data element, so long as it maintains a
reliable association with its message. Since a digital signature is unique to its
message, it is useless if wholly disassociated from its message.
As with the case of modern electronic data interchange (“EDI”) the creation
and verification processes are capable of complete automation (sometimes
referred to as “machinable”), with human interaction required on an exception
basis only. Compared to paper methods such as checking specimen signature
cards — methods so tedious and labor-intensive that they are rarely actually
used in practice — digital signatures yield a high degree of assurance without
adding greatly to the resources required for processing.
The processes used for digital signatures have undergone thorough technological
peer review for over a decade. Digital signatures have been accepted in several
national and international standards developed in cooperation with and accepted
by many corporations, banks, and government agencies. The likelihood of
malfunction or a security problem in a digital signature cryptosystem designed
and implemented as prescribed in the industry standards is extremely remote,
and is far less than the risk of undetected forgery or alteration on paper or of using
other less secure electronic signature techniques.
Public Key Certificates
To verify a digital signature, the verifier must have access to the signer’s public
key and have assurance that it corresponds to the signer’s private key. However, a
public and private key pair has no intrinsic association with any person; it is simply
a pair of numbers. Some convincing strategy is necessary to reliably associate a
particular person or entity to the key pair.
In a transaction involving only two parties, each party can simply communicate
(by a relatively secure “out-of-band” channel such as a courier or a secure voice
telephone) the public key of the key pair each party will use. Such an identification
strategy is no small task, especially when the parties are geographically distant
from each other, normally conduct communication over a convenient but insecure
channel such as the Internet, are not natural persons but rather corporations or
similar artificial entities, and act through agents whose authority must be
ascertained. As electronic commerce increasingly moves from a bilateral setting to
the many-on-many architecture of the World Wide Web on the Internet, where
significant transactions will occur among strangers who have no prior contractual
relationship and will never deal with each other again, the problem of
authentication/nonrepudiation becomes not merely one of efficiency, but also of
reliability. An open system of communication such as the Internet needs a system
of identity authentication to handle this scenario.
To that end, a prospective signer might issue a public statement, such as:
“Signatures verifiable by the following public key are mine.” However, others
doing business with the signer may for good reason be unwilling to accept the
statement, especially where there is no prior contract establishing the legal effect
Certain Certifying Authorities such as VeriSign of Australia offer all three classes
of Digital Certificates. The classes are differentiated by their assurance level—the
level of confidence that can be placed in the Digital Certificate based on knowledge
of the process used to verify the owner’s identity. The identification requirements
are greater for higher numbered classes—for example, a Class 1 Digital Certificate
verifies the owner’s e-mail address, while a Class 2 Digital Certificate offers the
additional assurance of verification of the owner’s personal identity.
An mentioned earlier, digital certificates is electronic record, which lists a public
key as the “subject” of the certificate, and confirms that the prospective signer
identified in the certificate holds the corresponding private key. The prospective
signer is termed the “subscriber. A certificate’s principal function is to bind a key
pair with a particular subscriber. A “recipient” of the certificate desiring to rely
upon a digital signature created by the subscriber named in the certificate
(whereupon the recipient becomes a “relying party”) can use the public key listed
in the certificate to verify that the digital signature was created with the
corresponding private key. If such verification is successful, this chain of reasoning
provides assurance that the corresponding private key is held by the subscriber
named in the certificate, and that the digital signature was created by that particular
subscriber.
To assure both message and identity authenticity of the certificate, the certification
authority digitally signs it. The issuing certification authority’s digital signature
on the certificate can be verified by using the public key of the certification authority
listed in another certificate by another certificate authority (which may but need
not be on a higher level in a hierarchy) ,and that other certificate can in turn be
authenticated by the public key listed in yet another certificate, and so on, until
the person relying on the digital signature is adequately assured of its genuineness.
In each case, the issuing certification authority must digitally sign its own certificate
during the operational period of the other certificate used to verify the certification
authority’s digital signature.
A digital signature, whether created by a subscriber to authenticate a message or
by a certification authority to authenticate its certificate (in effect a specialized
message) should be reliably time-stamped to allow the verifier to determine reliably
whether the digital signature was created during the “operational period” stated
in the certificate, which is a condition upon verifiability of a digital signature under
this chapter.
To make a public key and its identification with a specific subscriber readily
available for use in verification, the certificate may be published in a repository or
made available by other means. Repositories are on-line databases of certificates
and other information available for retrieval and use in verifying digital signatures.