Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
8Activity
0 of .
Results for:
No results containing your search query
P. 1
FILE HANDLING USING VISUAL BASIC 6

FILE HANDLING USING VISUAL BASIC 6

Ratings: (0)|Views: 278|Likes:
Published by api-19735720

More info:

Published by: api-19735720 on Nov 27, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

FILE HANDLING USING VISUAL BASIC 6.0
PART I - SEQUENTIAL FILES

- Sanchit Karve
born2c0de
printf("I'm a %XR",195936478);

CONTACT ME : born2c0de AT dreamincode DOT net
CONTENTS
\u2022
I. ASSUMPTIONS
\u2022
II. BASIC RELATIONSHIPS
\u2022
III. INTRODUCTION
\u2022
IV. SEQUENTIAL FILE HANDLING
\u2022
IV.1) PRINT# AND THE PROBLEM WITH HANDLING STRINGS
\u2022
V. SEQUENTIAL FILE HANDLING FUNCTIONS
\u2022
VI. SEQUENTIAL FILE HANDLING EXAMPLES
\u2022
VII. FILE-HANDLING ERRORS
\u2022
VIII. CONTACT ME
\u2022
*New*UPD ATE S
I. ASSUMPTIONS
The reader is expected to have a basic working knowledge of Visual Basic Data
Types, Arrays, Loops and Library Functions.
II. BASIC RELATIONSHIPS

You might have heard several terms in File Handling such as Fields, Records etc.
but may not know what they mean.
To understand it simply remember this set of relationships:
8 Bits = 1 Byte/Character
Many Bytes/Characters = 1 Field (or String)
Many Fields = 1 Record
Many Records = 1 File
Many Files = 1 Database

III. INTRODUCTION
As far as Visual Basic 6 is concerned, there are three modes in which a file can
be accessed.
\u2022
1) Text Mode (Sequential Mode)
\u2022
2) Random Access Mode
\u2022
3) Binary Mode

In the Text Mode, data is ALWAYS written and retrieved as CHARACTERS.
Hence, any number written in this mode will result in the ASCII Value of the
number being stored.
For Example, The Number 17 is stored as two separate characters "1" and "7".
Which means that 17 is stored as [ 49 55 ] and not as [ 17 ].

In the Binary Mode, everything is written and retrieved as a Number.
Hence, The Number 17 Will be stored as [ 17 ] in this mode and
characters will be represented by their ASCII Value as always.

One major difference between Text Files and Binary Files is that Text Files
support Sequential Reading and Writing. This means that we cannot read or write
from a particular point in a file. The only way of doing this is to read through
all the other entries until you reach the point where you want to 'actually'
start reading.
Binary Mode allows us to write and read anywhere in the file. For example we can
read data directly from the 56th Byte of the file, instead of reading all the

bytes one by one till we reach 56.

Just like the Binary Mode, the Random Access Mode allows us to gain
instant access to any piece of information lying anywhere in the file at a cost.
In this case, we must standardize each piece of information.
For example, if we need to store a few names in the file Random Access Mode
requires us to mention the length of the 'Names' Field.

Some Names might not fit and for the shorter names the space is inefficiently
used. Random Access Mode allows us to read or write data at a particular
record position rather than a byte position like in Binary Mode.

A Good Example of Sequential Mode is the Audio Cassette. If we have to
listen to a particular Song in the cassette, we have to play the tape right from
the beginning until we reach the beginning of the song.
And so obviously, CDs, DVDs etc. are examples of Binary Mode ( and even Random
Access Mode )

Part-I deals with Sequential Files,Part - II with Binary Files and [url=about:Tutorial Coming
Soon!]Part-III[/url] with Random Access Files.
You should readPart - II of the VB6 File Handling tutorial series if you wish to read aboutAccess
Permissions and Locks. Read Section VII : ACCESS-LOCKS for more information on Locks and
Access Permissions for Sequential Files.
III. SEQUENTIAL FILE HANDLING
To open a File in Sequential Mode, we need to use the Open Command like this:
CODE
Open <FILENAME>For <MODE> As<FILE#>
FILENAME: Contains thePath of theFile to be opened.
MODE
:Can be INPUT,OUTPUTor APPEND
FILE#
: Any number from 1 to 255 preceded by a #
Each File irrespective of its mode requires a file handle(FILE#). All operations

Activity (8)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
Blade liked this
manish_ycce2006 liked this
chandrashekar09 liked this
kps103 liked this
durgathapa liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->