Visual Basic Programming 6.0 Lesson 1
Visual Basic Programming 6.0 Lesson 1
INTRODUCTION
Program is a set of instructions and commands to a computer to perform a specific task.
Hence programming is the process of writing these set of instructions and commands to a
computer
Commands e.g. open, close, save etc
Programme Language-
Is a language which can be used to write the programmes.Programmes is a written
instruction (codes) in various programming language. Some directly understandable by
the computer and others that require intermediate steps.
A) Low-Level languages
Consist of
i) Machine Language(I’s and O’s)
Natural language of a particular computer which is a collection of very detailed
instruction that control computer internal circuits. It is defined by the hardware design
of that computer. It consists of strings of bits (I’s & O’s) that instruct computer to
perform the most elementary operations.
ii) Assembly Language
Since machine language was tedious to develop, English like-Abbreviation were
developed to present elementary operations of the computer thus to an auto-translator
called Assembler were developed to convert assembly language programs to a
machine language.
B) High-Level languages
These are languages which are compactable with human languages and notations.
Allows programmers to write everyday English-like instructions and mathematic
notations e.g.
iv) JAVA (Used for designing Web-Page Object Oriented to run over the Internet)
1
vii) C++ (Object Oriented Languages)
Computer languages have developed over the years. This development is referred to
as generations
4th Generation Languages
Forpro, Visual Basic, JAVA, Visual, C++ etc
ii) Coding
This is the writing of program instructions using the language Basic
2
V.B – Contain 3 tabs
New –New projects
Exist – Already created projects
Recent- Opening recently created projects
2. Menu Bar
Display the commands for developing over maintaining and executing programs
e.g. File Edit, View, Project, Format, Debug etc
3. Toolbar
Contains icons (Buttons) for commonly used commands in the programming
environment
5. Toolbox(General)
Contains controls (objects) used to customize the form.
i) Textbox (txt)
Textbox is a control used for accepting user input can also display text as an
output.
3
vi) Combobox (cbo)
Combobox are controls that provides short list of items
xiv) Timer is a control that performs a task that specify the interval
Consist of:
Form 1(frm)
List all the forms and modules in your current
Project 1
Is the collects of file you used to build an applications
Contains three buttons i.e. View code-which shows a window for writing V.B codes.
View object-display the form.
Toggle Folders-It toggles (alternately hides or shows) form folders.
Form Folder contains a list of all the forms in the current object
Properties Window
List the properties settings for the selected forms or objects. A properties is a list
characteristics or attributes of an object e.g. size, colour, caption, name etc
Properties are listed alphabetically or categorized (keep in categorizes) in appearance,
behaviour, font etc
Editor Window
4
CREATING AN APPLICATION
As three major steps.
2. Set properties.
This involves setting the properties for each of the objects you’ve created
including the form
3. Writing codes.
A code consists of language statements, Constance and decorations.
To open the code window click on view code button or double click on
view code form or the control for which you want to write the code.
Example 1.
5
From Run menu, select or click the button on the tool bar. This terminates
the Programme execution and places the IDE in design mode.
Saving a project
V.B creates a separate file for each form and assigns it an extension frm
and an additional file for the projects and assigns it an extension vbp.To
save from file menu, select save project,V.B prompts you to save the
forms hence specify its name and click on save button.
Example 2
A program which prints a line of text on the form after receiving an event.
6
(specified in the name property), an underscore and the event name e.g.
Private sub cmdprint_click ( )
Example 3
7
Private Sub cmdcalculate_Click ( )
Dim Length As Integer
Dim Height As Integer
Dim Area As Integer
Length = txtlength.Text
Height = txtheight.Text
Area = Length * Height
txtarea.Text = Area
End Sub
MEMORY CONCEPTS
8
Multiplies values in length and height in memory location and
assigns the results to Area memory location
- txtarea.text=Area
Get the value in Area memory location and displays it or
output it as text in txtarea.text
- The syntax for declaring a variable is DIM ( variable name
AS(variable datatype)
Data types
9
Dim length%
Dim area%
Constants
They are declared with the key word const.The syntax for
declaring a constant is const. (constant name) = (value)
Example 4
10
Private Sub cmdfind_Click ()
Dim area As Double
Dim radius As Double
Const pi = 22 / 7
Radius = txtradius.Text
Area = pi * radius ^ 2
txtarea.Text = area
End Sub
Control Prefix
Form frm
Label lbl
Textbox txt
Command button cmd
Combobox cbo
Optionbutton opt
Line lin
Data dat
Adode ado
Frame fra
11
Txtdisplay.fontbold = true
Txtdisplay.ToolTipText= “This is a textbox”
Commenting your Code
-A Comment or remark is a short statement written inside the Programme code for the
purpose of explaining what the code is achieving.
-It is not read (executed) by visual basic hence it does not interfere with the Programme
execution. A comment is started with either an apostrophe (‘) or Rem.It is highlighted in
green color.
Mathematical Operators
Performs arithmetic manipulation of numbers. They include:-
Logical Operators
i) AND- Returns true if both expressions on either side of it are true and
false if one or both expressions are false.
ii) OR- Returns true if any one of the expressions or either side is true or
both, and false when both expressions are false.
12
iii) XOR- yields true only if one of the expressions on either side of it is
true, but not if both expressions are true. Returns false when both
expressions are false.
iv) NOT-Reverses the logical state of the expression that is in its
immediate right e.g. if a mango is not a fruit, then run.
v) EQV-Compares whether the expression on both sides are equivalent.
Comparison Operators
i) >-Greater than
ii) <-Less than
iii) =-Equals
iv) <>-Not equal
v) >=-Greater than or equal to
vi) <=-Less than or equal to.
NB
Comparison equal sign and assignment equal sign are similar. The assignment
operator always appears to the right of a variable and to the left of the value
that is being assigned to the variable.
13
Operators Precedence
i) Evaluate:
2*5^2 + 3 * 5 +7
2*25 +3*5+7
50 +15+7
65+7
= 72
ii) P*r^q+w/x-y (BODMAS)
Concatenation Operators
14
black & “board” yields blackboard
1 & 2 yields 12
“1” & “2” yields 12
Y= “1”
X = “7”
Print y + x
Print y & x
End sub
15
Program which test whether a year is leap or not and report the number of days
in it.
Msgbox Function
Is used to display a message
The syntax is Msgbox (prompt, button + icon, title)
Prompt
Must be supplied when calling the message box and it is the message that appears on
the box
Button + Icon
These are values that specify the kind of buttons and icons to appear on the message
box e.g. for buttons:-
i) Vbok only displays ok button.
ii) VB yesno displays Yes and No button
iii) VB yesnocancel displays Yes, No and Cancel button
iv) VB okcancel displays ok and cancel
v) VB retrycancel displays Retry and Cancel button
vi) VB abortretryignore display Abort, Retry and Ignore button
Title
16
It is the text that appears on the title bar of the box. It is optional and if omitted the title of
the application appears
Inputbox ( ) Function
Is used to display a prompt in a dialog box and wait for the user to input text or click a
button.
The syntax is Inputbox (prompt, title, default, xpos, ypos)
Prompt
Is the guiding statement that appears on the dialogbox
Title
Is the text that appears on the title bar of the dialogbox.It is optional and if omitted the
title of the project or application appears in the dialogbox title.
Default
This is a text which appears on the inputbox default.
Assignment
Develop a program which displays the following message box
17
Floppy 3 1/2
A. Drive Is not accessible
Solution:
Outcome =Msgbox (“A Drive A is not Accessible”, vbcritical +
vbAbortretrycancel,”Floppy 3 ½”)
Exercise 1.
Write a program which prompts a user for the year and returns whether the year is a
leap year or Not and also the number of days in that year.
CONTROL STRUCTURE:
18
Introduction
Normally statements in a program are executed one after the other in the order in
which they are written. This is called sequential execution, but the execution can be
transferred to another line other than the next. This referred to as transfer of control.
All programs can be written in terms of three structures.
Namely:
1. Sequence structure: Unless directed otherwise, the computer executes VB
statements one after the other in the order in which they are written.
2. Selection structure or decision structure is used to choose among alternative
cause of action
a) IF/THEN
b) IF THEN ELSE
c) SELECT CASE
3. Repetition or Loop or Iteration structures:-Allows the programmer to specify that
an action is to be repeated based on the truth or falsity of some condition
They include:-
Do/while…loop
Do/until…loop
For…next
Exercise 2
A bank wishes to develop a program that will calculate the amount of money on
deposit at the end of 10 years. The bank’s representative should enter the initial
deposit amount and the interest rate. The amount of money on deposit at the end of
each year is calculated and displayed on a listbox.
Using the For/Next loop write a program that computes the compound interest for the
10 years. Use the formulae amount = principle *(I + Rate) ^years.
Exercise 3.
19
Explain the function of the following v.b statement
‘lstdisplay.additem”year”&space$(7)&”Amount on Deposit”
Introduction to Algorithms
Algorithm is a sequence of steps which result in a plan or strategy on how to go about
in solving a problem. There are three major ways of presenting an algorithm i.e.
pseudocode, flowcharts and Jackson structure Diagrams
PSEUDOCODE
Is an artificial informal language (English like statements) that helps programmers
develop an algorithm that will be converted to a structure program.
e.g. the pseudocode for display student remarks can be written as
-Enter the marks
-If mark is greater than or equal to 60
- Display “passed”
- Otherwise display “Fail”.
FLOW CHART
20
SYMBOLS:
Operation Start/Stop
Flow Lines
Decisio
n
4 Connectors
Input/Output
21
Start
Is
Num
1<num2
YES Num 1>, NO
Num 2
Display num 1 is
greater than num 2 NO YES
Display num 1 is
equal to num 2
Display num 1 is
less than num 2
Stop
Loop flowcharts
e.g. Flow Chart which prints values x = 0 to 10
22
Start
X=
0
Print X X=X+1
Is No
X
>10
Yes
Stop
Performs an indicated action only when the condition is true otherwise the ACTION IS
SKIPPED. The IF/THEN/ELSE selection structure allows the Programmes to specify that
a different action is to be performed when the condition is True than when the condition
is False e.g. Kamau owns an umbrella and a jacket. He wears the jacket if it gets cold and
carries an umbrella if it rains, otherwise he carries nothing. This can be written as
23
Select Case
Is a multiple selection structure. It is similar in function to the If statement. Its purpose is
to replace the if statement in situations where you would be forced to use too many Elseif
clauses e.g.
Example
24
Case else:
Number = msgbox(“Numbari uliyoandika haijasajiliwa”)
End select
Arrays
A program to determine arrays
Private sub end print _ click ()
Dim MyArray (9) as integer
Print “positions” & space (7) & “Values”
For X = LBound (myARRAY_ to ubound (myArray)
myArray (x) = 2 + x
print x & space $(7) & myArray (x)
next
end sub
25
Student table
Add fields, click on it.
Admission number (ADMNO) Primary key
First name
Middle name
Last name
Home address
Date of birth (DOB)
Adm Date
Parent’s ID
Form ID
Gender
Fees balance
Parent’s Table
Parent’s ID (Primary Key)
Father’s Address
Father’s Telephone
Mother’s Names
Mother’s Address
Father’s Profession
Mother’s profession
Adding AdoData control
The Ado Data control needs a form to an existing database control is
connected to a set of record on the target database. This sets of
records constitutes the record set object of the data control depending
on the cursor type property of the data control. The table record can
be added. Modified or deleted on the target database from the visual
Basic form. The custom property is the Name including the path which
the data control is connected. The record source property holds the
name of the table to which the data control is connected.
The cursor type can be:-
i) Ado penkey set – which specifies that the record can be
added, altered or deleted and can once be done on a single
table.
ii) Adopen dynamic – This is dynamic set of record that maybe
used to add, alter or delete records from underline table. This
type of cursor can contain field from one or more table.
iii) Adopenstatic – This type of cursor means the record cannot
be updated.
BOUND CONTROL
Is a data aware control that can provide access to a specific field or
fields in a specific field or fields in a database through the Ado data
control. It is typically bound to Ado data control and data field.
26
Click on a text box e.g Txt First Name and set it data sources property
to Ado student by selecting.
NB: Field property is a property of record set object of the data control.
This property contains the name of all the fields that are in the record
set in order to referred to a particular fields. Its name is given in
bracket and enclosed in quotas offer the record field. This references
content of that field for the current record.
SEQUENCE
In sequence control structure, the computer needs instructions from a
program file. Starting from the first top lines and proceeding
downwards one-by-one to the end. This is called sequential program
execution.
Start Statement 1 Statement 2 Statement 3
27
SELECTION
In selection control, execution of statements depends on a condition
that returns true or false. The condition must be a Boolean expression
is x > = 20. In such a case the condition is true if x is equal to or
greater than 20. Any other value that is less than 20 is therefore false.
Generally, the four types of selection controls used in most high-level
programming languages are:-
IF ---THEN
IF ---THEN---ELSE
NEST IF
CASE Selection
IF -----THEN
IF ___THEN selection is used if only one option is available. In a school
environment, the administration may decide to reward only those
students who attain a mean mark of 80% and above the rest are
ignored
Pseudo code
If mark > = 80 then
Print”. Give reward”
End if
Mark> yes
= 80?
No
Print” Reward”
Stop
28
IF < condition> THEN
Statements;
End if
IF _____THEN____ELSE
IF ___THEN ___ ELSE selection. When there are two available options
Example is a player in a football match does a mistake is given a red
card. Otherwise a given yellow card as warning.
Pseudo segment
IF fault = Serious THEN
PRINT “Give red card”
ELSE
Print “ Give yellow card”
END IF
Flow chart extract
start
No Fault = yes
serious
Stop
Nested IF selection
Nested IF selection is used where two or more options have to be
considered to make a selection.
Example in Olympics track event Medals are awarded for the first three
athletes.
29
IF position = 1 THEN
Medal = “Gold”
ELSE
IF Position = 2 THEN
Medal = “Silver”
ELSE
IF Position = 3 THEN
Medal = “bronze”
ELSE
Medal = “nil”
END IF
END IF
END IF
Flow chart
start
No No No
Position 1? Position 2? Position 3?
Medal = “Nil”
Print Medal Stop
This general format of the Nested IF
IF <Condition> THEN
Statements
ELSE
IF < condition> THEN
Statements
ELSE
IF<condition> THEN
Statements
ELSE
Statements
END IF
END IF
END IF
CASE Selection
30
CASE selection is an alternative to the nested IF especially where there
are several options to choose from. It is only to reduce many links of
code.
The b……… expression for the case selection can only be expressed
using integers and alphabetic characters only
Pseudo code
CASE average OF
80……..100: Grade = ‘A’
70………79: Grade = ‘B’
60………69: Grade = ‘C’
50………59: Grade = ‘D’
40………49: Grade = ‘E’
ELSE
Grade = ‘F’
END CASE
No No No
Average Average Average Average Average
80-100 70-79 60-69 50-59
40-49
Note: The flow char Is not different from that of the Nested IF construct
Iteration (Looping)
31
Iteration also referred to a looping repetition is designed to execute
the same block of code again and again until a certain condition is
fulfilled.
Example, assume that you are writing a program that will use the
same formula to calculate the average marks of three subjects for
each student in a class and that the student records are stored in a
computer file.
To calculate the average score for each student in a class the program
should repeatedly read record by record from the file then se the
formula after each read operation to calculate the average.
Pseudocode
WHILE balance > 0 Do
Withdraw cash
Update account
END WHILE
Flowchart extract
No
Exit loop
In our cash above,
1. The condition balance > 0 is first tested.
2. If it is true, the account holder is allowed to withdraw cash.
3. The program exits the loop once the balance falls to zero.
32
Example consider the ATM cash withdraw case. If the REPEAT -----
UNTIL is used, then the client will be able to withdraw the cash at least
once since availability of balance is tested at the end of the loop.
Pseudo code
REPEAT
Withdraw cash
Update account
UNTIL balance < 0;
Flow chart extract
Withdraw cash
Update account
Balance
> 0?
Exit loop
Pseudo code
FOR Count = 1 to 10 Do
PRINT “ Enter a number (N)’’
INPUT N
Sum = Sum + N
END FOR
33
Display Sum
Yes
No
SUM
Explanation
The FOR loop in the problem above function as follows:
1. The loop variable (Count) is first initialized to the lower limit, in
this case a value of 1.
2. The lower limit is then tested against the upper limit whose value
is set to 10.
3. If the lower limit is less than or equal to 10, the program prompts
the user to enter a number N, otherwise the computer exits the
loop.
4. After the last statement in the loop has been executed, the loop
variable count is intermitted by a 1 and stored in the lower limit
i.e. lower limit = count +1.
5. The lower limit is then stored in count and stop (2) is repeated.
The For loop can also be used to count downwards from the upper limit
to the lower limit. For example, in the above against the lower 1 as
follows
34
For Count = 10 DOWN to 1 Do
Therefore the general format of the For loop can be represented using
two sets of algorithms.
Flowchart extract
A For loop that counts upwards
Statement
No
Condition?
35
yes
Statements
NO
Condition?
Yes
PROJECT 1
Write a program that can be used to find the roots of a quadratic
expression.
2x2 + b x + c = 0
The formulas to solve the values of x in this expression are:
X1 = -b – Sqr (b2 - 4ac)
2a
X2 = b + Sqr (b2 - 4ac)
-
2a
X = -b i.e if b2 = 4ac = 0 or
2a
b2 = 4ac
36
To crate the project, proceed as follows:
1) Test whether b2 is larger than or equal to 4* a* c. if it is true,
then:
Explanation
1. The expression bˆ 2 – 4* a * c is first assigned to variable Z
PROJECT 2
The case constructs.
‘Display weekday
Dim D As integer
SELECT CASE D
CASE 0
Print (“Sunday”)
CASE 1
Print (“Monday”)
CASE 2
Print (“Tuesday”)
CASE 3
Print (“Wednesday”)
CASE 4
Print (“Thursday”)
37
CASE 5
Print (“Friday”)
CASE 6
Print (“Saturday”)
CASE ELSE
Msgbox (“Error – That is not a day in the week”)
End .SELECT
PROJECT 3
Write a program using the DO loop that will write numbers between 1
and 20 on the screen then stop.
Solution:
1. Double click the form to display its code window.
2. Add the following code listing between the private sub form –load
and End sub.
X=0
Counter = 0
Do WHILE counter < = 20
X=x+1
Counter = Counter + 1
Print x
Loop
Do While loop
Open the project and replace its code with the code below
Dim x As integer, counter as integer
X=0
Counter = 0
While counter < = 20
X=x+1
Counter = counter + 1
Print x
Wend
The FoR – NEXT Loop
Open the project for and replace the code with the listing below:
Dim Number As Integer, Counter as Integer
Number = 0
FoR Counter = 1 To 20 STEP 2
Number = Number + Counter
Print Number
Next Counter.
FUNCTION CALL
Function Call
Date Z = Date ( )
38
Exp Z = Exp (w)
Sqr Z = Sqr (w)
Log Z = Log (w)
Str Z = Str (w)
Cos Z = Cos (w)
Abs Z = Abs (w)
Ucase Z = Ucase (w)
Int Z = Int (w)
Time Z = Time
Format Z = Format
Description
1. Returns the current date
PROCEDURE
It is a block of code that perform a specific task. They allow a program
to be broken down to small functions unit or modules. In V. B there are
two types of procedures.
Sub procedure and Function procedures
SUB – PROCEDURES
Is a block of V.B Code that appears between sub and End sub.
Sub procedure can either be private or public. A private sub procedure
is not available for use by any module other than module in which it is
contained.
A public sub procedure is available for use by external modules. There
are two types of sub procedures.
i) Event procedures
Is a sub procedure that is invoked (activated) by an event.
39
Cmd checks the name of an event
Sub-procedure is derived from the name of a control that is associated
and the event for which the procedure is to be written.
ii) General procedure
Is a sub procedure i.e not associated with any event hence general sub
procedure has to be invoked (called) by name. Since there is no way in
which the system can invoke them automatically. It can either be
public or private, but generally its better to have public general sub-
procedure since they can be accessed from any module in your
project. The naming route for general procedure are similar to naming
variable.
Example:
Assuming you’ve a general sub-procedure that says goodbye to the
user before application closes then it looks as follows:
General sub-procedure
Public sub-goodbye ( )
Msgbox ( “ goodbye”)
End sub
Exit end Exit
40
Msgbox (“The Square is “& square procedures)
End sub
Parameter:
Is a data value that is passed to a procedure during a call. i.e whe it is
invoked. It is also known as an argument.
The list argument and their data types that are required by the
procedures are always specified in the procedure declaration and held
(that come after the procedure name)
Example
Suppose we need a function that calculate the interest and in a saving
account.
The function will require the amount in the account the interest rate
and the period of time the money has been in the account. The
function then return the interest. The code will look as follows:
Public Function Interest (amount @ Rate #, time #) AsDouble
Interest = Amount x Rate/100 x time
End Function
When the Function is being called all the required parameter must be
specified.
Suppose the interest will be calculated after you click on a button
called cmdinterest and value display on a text box called txtinterest,
then the event procedure will be
Private sub cmdinterest_click ( )
Dim simple interest as Double
Dim Amount as Currency
Dim Rate as Double
Dim Time as Double
Amount = Txtamount.Text
Rate = TxtRate.Text
Time = Txttime/Text
simpleInterest = interest (Amount, Rate, Time)
Txtinterest.Text = simpleInterest
End sub
Variable Scope
41
Is visibility of a variable within a variable. There are two type of
variable scope:
(i) Global – A variable that has been declared in the general
section of a module is known as a Global variable. It can be
read and after by any procedure in the module it is declared
by using the key word e.g public length as integer
Declaring an array
To declare an array, use the statement Dim Array Name (n), where
n stands for the number of elements in the array. For example:
Dim Scores (4) is an array that holds five elements.
An elements is an item in an array that can be accessed using the
array variable name and a subscript. For example consider an array
of 5 elements called “Scores to display the 4th element use:
Score 4 = Scores (3)
Print Score 4
The value stored in the variable scored 4 print on the form. To store
a value in an array variable use the statement Array Variable
(index);
For example, to assign a numeric constant 90 to the fifth cell use
Scores (4) = 90
This statement will assign a value 90 in the cell 4 th of the array.
42
NB: If the array was very large and you wish to read or enter values
in it, it would be read or enter values in it, it would be very tedious
entering a value cell by cell i.e
Score (0) = 10
Score (1) = 20
Score (3) = 30
Score (n) = x
To avoid this the FoR …..loop, can be used.
Remember that this loop is used where the number of iterations are
pre-determined hence its suitability for use with arrays.
For example, if you wish to request the user to enter six values in
array named A, the following FoR loop can be used:
Dim A (5) As Integer
Dim Index As Integer
Private Sub Enter Array Values ( )
For index = 0 to 5
A (Index) = Val (TextI. Text)
Next Index
End Sub
Notice that the array is declared this time outside the subroutine in
order to make it a general procedure that can be accessed by other
subroutines.
To Display values of the array on the form the following statement
can be used.
Private Sub-Display Array valves ( )
For index = 0. To 5
Text2. Text = Str (A (Index) )
Next Index
End Sub.
43
Records
A record comprises of a series of related data items, (fields). They
differ from arrays in that whereas all elements in an array are of the
same data type, data items in a record may differ in type. For
example, when you want to store a students record with the fields
Name, Registration number and date of Birth in a file as a unit, then
you can define a record that would hold all this data items in one
structure. For example the following declaration will create student
details record.:
Array of Records
A set of user defined data types can be stored and accessed in arras
too. Consider the record declared below:
Type student
RegistrationNumber As Integer
Name As string * 20
End Type
An array of the student record can then be declared as follows:
Dim StudentArray (39) As student.
This means that the array can store fourty student records. To
access a field in the array of records use the statement:
44
Arrayname (index). FieldName e.g
StudentArray (20). Name will return the name of the student whose
record is in the 20the cell.
Example . s.
Arrays should be declared with Dim in the general declarations
area, or with Redim in a procedure.
Examples of array declarations;
Dim Results (50) As Integer
This creates a one dimensioned array of 51 integers numbered from
0 to 50
Dim Employees (1….200) As string.
This will hold 200 text items, each of any length up to 64k. in this
case the subscripts numbering starts at 1.
Dim Table (10,20) As single.
This array has two dimension when you could think of as 10
columns and 20 rows.
Dim 0 X 0 Grid (3,3,3) As Integer.
It is a three dimension noughts and crosses with 4 layers of 4 rows
and 4 columns.
ARRAYS
Array Contents
Names (0) Fred
Names (1) Jim
Names (2) Sally
Names (3) Dick
Names (4) Karen
Names (5) Jo
45
This array would have been set up with the line:
Dim Names (5) As string
This has 6 elements, numbered 0 to 5
Each can be accessed individually to read or to change its data by
specifying its subscript.
Print Names (2) ‘displays Sally
Names (4) = Katy ‘ replaces Karen with Katy
0 x
1
This could be the board for noughts
and crosses. 2 0
It would be declared with the
line:
Dim 0 x 0 (2, 2) As string
In the illustration, 0 x 0, (0,0) hold the weekly wages of 20 workers,
and will require a little over 52*20*8 = 8320 bytes, just over 8kb.
Dim Marks (10, 30,25) As Double
This will hold the marks of 10 classes of students, with up to 30 in a
class and 25 assignments per student.
It will need 10*30*25*8 = 60,000 bytes of storage.
46