FILE OPERATION

File opening, closing file, edit file, writing file, deleting file, reading file.

OPENING FILE

Using OPEN statement a VB program always has to open a file before the program can read or write data to the file. The OPEN statement before verious task.

  • Locating a file.
  • Making shore the file exists.
  • Create some folder & entries the manage the fide way the file is open.

SYNTAX

OPEN Str File Name [formed] As [#] int File number

Str FILE  NAME

A string value or string variable that hold the file name.

MODE

Determines how VB open/user the file. Three types of modes.

1. Append.

2. Input.

3. Output.

Int FILE NUMBER

Value represent a number from 1 to 225 Associated with a file when the file open & released at the time of file.

EXAMPLE

OPEN“d:/data/myfile.dat”ForAppendAs#1

USE OF FREE FILE

  • Built-Inn function.
  • Accepts no arguments.
  • Returns next available file number value.
  • Int file number = Free file ().

CLOSING FILE

Close statement perform opposite jobs from it closes the file by writing any final data to the file. Relasing the file to other application & given the file number back to application.

SYNTAX

CLOSE [[#][int File Number], [#] [int File number]….]

EXAMPLE

Close1 (File number 1) or

Close3 (File number 3)

Close.

DELETING FILE

KILL command is used to delet one or more files.

SYNTAX

Kill string.

EXAMPLE

Kill“d:/data/myfile.dat”

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s