SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
Presentation
      on
File Handling
Contents
   Definition Of File
   Types Of Files
   Operations on File
    Opening A File
    Closing A File
    Writing Data To A File
    Reading Data From A File
    Detecting The End of File
    Storing A File
    Demo Application
Definition Of File
   A File is a collection of data stored on a
    computer’s disk.
   Information can be saved to files and later
    reused.
Types Of Files
   There are three types of files.
1)   Sequential Access Files
2)   Random Access Files
3)   Binary Files
Sequential Access File
   A sequential access file is a stream of data that

    must be read from its beginning to its end.

   To read a record that is stored in the middle or at

    the end of sequential access file an application

    must read all the records in the file before it.
Random Access File
   In Random access file Records must be identical

    in length and may be accessed in any order.

   An application may immediately jump to any

    record in a random access file without first

    reading the preceding records.
Binary File
   In binary file data is stored in binary form not in

    plain text.

   The records in binary files may vary in length.

   Binary files are usually smaller than text files but

    user cannot view their contents with text editor.
Binary File
   In binary file data is stored in binary form not in

    plain text.

   The records in binary files may vary in length.

   Binary files are usually smaller than text files but

    user cannot view their contents with text editor.
Operations on File
File Open Mode
Input           Used with sequential acess file.
                Data will read from the files.
Output          Used with sequential access files .
                Data will be written to the file.
Append          Used with a sequential access file.
                Data will be written to the end of
                the file.
Random          This file is opened for random
                access . If the file does not
                exist,it is created.
Binary          The file is opened in binary mode.
                If the file does not exist , it is
                created .
Opening A File
   Open statement is used to open a file.



Syntax :


Open*filename*for mode as # filenumber [len=recordlength]
Contd..
   When a sequential file is opened , visual basic

    creates a file buffer.

   A file buffer is a small holding section of memory

    that data is first written to.
Closing A File
   Close statement is used to close a file.

         Syntax :


             Close [filenumberlist]



• In syntax, Filenumberlsit is one or more file
  numbers separated by commas.
Contd..
   The # symbol must appear with each file number.

   Example close #1,#2

   If user don’t specify any file number , visual basic

    closes all the files the applications has opened.
Writing data to a File
   Data may be written to a file that is opened in

    either output or append mode.

   The write statement is used to write a data to the

    file.
             Syntax


              Write # filenumber, [itemlist]
Reading data from a file
   Data may be read from a file that already exist

    and is opened in input mode.

   The input statement is used to read data from a

    file.
            Syntax

            Input # filenumber, itemlist
Opening a file in append mode
   When a file is opened in append mode data is

    written to the end of the file.

   If the file is already exist its contents are not

    erased.

   If the file does not exist it is created.
Contd..
.
      Syntax

    Open filename for append as #1
Detecting the end of the file
   The EOF function detects when the end of file has been

    reached.

                Syntax


               EOF(file number)



     The function proves true if the end of file has been

    reached or false if the end of file has not been reached.
Application on file handling
Filehandling
How to apply picture on command
             button

   Select the command button.
   Draw it and then go to properties window.
   Change the style property to 1-graphical.
   Select the picture option.
   Select the picture user want to apply.
How to draw a shape
•Select the shape option from the toolbox.
•Then go to shape properties and select any
option.




                                        Shape
                                        option
Coding Of this Form
   Private Sub cmdappend_Click()

   Unload Me

   frmappend.Show

   End Sub



   Private Sub cmdclose_Click()

   Unload Me

   End

   End Sub
Contd….
   Private Sub cmdcreate_Click()

   Unload Me

   frmcreate.Show

   End Sub

   Private Sub cmdread_Click()

   Unload Me

   frmread.Show

   End Sub

   Private Sub cmdwrite_Click()

   Unload Me

   frmwrite.Show

   End Sub
Filehandling
Contd….
   Dim fname As String

   Dim productname As String

   Dim companyname As String

   Dim price As Integer

   Dim intcount As Integer

   Private Sub cmdclose_Click()

   Unload Me

   End

   End Sub
Contd….
   Private Sub cmdcreate_Click()

   fname = InputBox("Enter the File Name")

   Open fname For Output As #1

   For intcount = 1 To 4

   MsgBox " Enter the product details " & FormatNumber(intcount, 0)

   productname = InputBox("Enter the Product name")

   companyname = InputBox("Enter the Company name")

   price = Val(InputBox("Enter the Price"))

   Write #1, productname, companyname, price

   Next intcount

   Close #1

   End Sub
Control Array
   A control array is a group of controls all of the
    same type.
   The control array has a name but the individual
    controls in the array donot.
   To refer to a member of a control array, the
    syntax is:
   ControlName(Index)[.Property]
How to create a control array
   Select (command button,text box ,label etc).

   Then draw it.

   Then copy it and paste it.

   It will ask do you want to create a control array

    then click yes.
Filehandling
Filehandling
Coding
   Private Sub cmdappend_Click()
   Open "d:aman.txt" For Append As #1
   productname = "laptop"
   companyname = "samsung"
   price = 33000
   Write #1, productname, companyname, price
   Close #1
   End Sub

 Private Sub cmdclose_Click()
 Unload Me
 End
 End Sub
Filehandling
Coding
 Private Sub cmdclose_Click()
 Unload Me
 End
 End Sub


   Private Sub cmdwrite_Click()
   Open "d:aman.txt" For Output As #1
   productname = "laptop"
   companyname = "samsung"
   price = 33000
   Write #1, productname, companyname, price
   Close #1
   End Sub
Filehandling

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Object oriented approach in python programming
Object oriented approach in python programmingObject oriented approach in python programming
Object oriented approach in python programming
 
File Handling in Python
File Handling in PythonFile Handling in Python
File Handling in Python
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Lecture 1 introduction to vb.net
Lecture 1   introduction to vb.netLecture 1   introduction to vb.net
Lecture 1 introduction to vb.net
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Strings in c#
Strings in c#Strings in c#
Strings in c#
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
 
Textbox n label
Textbox n labelTextbox n label
Textbox n label
 
Xml
XmlXml
Xml
 
Java awt
Java awtJava awt
Java awt
 
Visual Basic menu
Visual Basic menuVisual Basic menu
Visual Basic menu
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
 
Files in c++ ppt
Files in c++ pptFiles in c++ ppt
Files in c++ ppt
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
 
Std 12 Computer Chapter 1 Creating Html Forms Using KompoZer
Std 12 Computer Chapter 1 Creating Html Forms Using KompoZerStd 12 Computer Chapter 1 Creating Html Forms Using KompoZer
Std 12 Computer Chapter 1 Creating Html Forms Using KompoZer
 
Python programming : Classes objects
Python programming : Classes objectsPython programming : Classes objects
Python programming : Classes objects
 
java token
java tokenjava token
java token
 
Files and streams
Files and streamsFiles and streams
Files and streams
 
Input processing and output in Python
Input processing and output in PythonInput processing and output in Python
Input processing and output in Python
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 

Andere mochten auch

Creating, Updating and Deleting Document in MongoDB
Creating, Updating and Deleting Document in MongoDBCreating, Updating and Deleting Document in MongoDB
Creating, Updating and Deleting Document in MongoDBWildan Maulana
 
Data file handling
Data file handlingData file handling
Data file handlingTAlha MAlik
 
Files and file objects (in Python)
Files and file objects (in Python)Files and file objects (in Python)
Files and file objects (in Python)PranavSB
 
Symmetric multiprocessing (smp)
Symmetric multiprocessing (smp)Symmetric multiprocessing (smp)
Symmetric multiprocessing (smp)rayhan basher
 
Vb net xp_10
Vb net xp_10Vb net xp_10
Vb net xp_10Niit Care
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++Vineeta Garg
 
Vb.net session 01
Vb.net session 01Vb.net session 01
Vb.net session 01Niit Care
 
Operating system introducton and tyes
Operating system introducton and tyesOperating system introducton and tyes
Operating system introducton and tyesNancy Verma
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NETrchakra
 
file handling c++
file handling c++file handling c++
file handling c++Guddu Spy
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notesWE-IT TUTORIALS
 

Andere mochten auch (20)

File handling
File handlingFile handling
File handling
 
File Handling in C++
File Handling in C++File Handling in C++
File Handling in C++
 
Creating, Updating and Deleting Document in MongoDB
Creating, Updating and Deleting Document in MongoDBCreating, Updating and Deleting Document in MongoDB
Creating, Updating and Deleting Document in MongoDB
 
Data file handling
Data file handlingData file handling
Data file handling
 
Chap 1 c++
Chap 1 c++Chap 1 c++
Chap 1 c++
 
Files and file objects (in Python)
Files and file objects (in Python)Files and file objects (in Python)
Files and file objects (in Python)
 
Menu vb
Menu vbMenu vb
Menu vb
 
Symmetric multiprocessing (smp)
Symmetric multiprocessing (smp)Symmetric multiprocessing (smp)
Symmetric multiprocessing (smp)
 
File handling
File handlingFile handling
File handling
 
Standard Algorithms
Standard AlgorithmsStandard Algorithms
Standard Algorithms
 
Vb net xp_10
Vb net xp_10Vb net xp_10
Vb net xp_10
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++
 
Vb.net session 01
Vb.net session 01Vb.net session 01
Vb.net session 01
 
Real time operating system
Real time operating systemReal time operating system
Real time operating system
 
Operating system introducton and tyes
Operating system introducton and tyesOperating system introducton and tyes
Operating system introducton and tyes
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
 
file handling c++
file handling c++file handling c++
file handling c++
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notes
 
Oops ppt
Oops pptOops ppt
Oops ppt
 

Ähnlich wie Filehandling (20)

Filepointers1 1215104829397318-9
Filepointers1 1215104829397318-9Filepointers1 1215104829397318-9
Filepointers1 1215104829397318-9
 
Basics of file handling
Basics of file handlingBasics of file handling
Basics of file handling
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handling
 
Filehandlinging cp2
Filehandlinging cp2Filehandlinging cp2
Filehandlinging cp2
 
Chapter - 5.pptx
Chapter - 5.pptxChapter - 5.pptx
Chapter - 5.pptx
 
Chapter4.pptx
Chapter4.pptxChapter4.pptx
Chapter4.pptx
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
 
Data file handling
Data file handlingData file handling
Data file handling
 
Chapter10
Chapter10Chapter10
Chapter10
 
UNIT 5.pptx
UNIT 5.pptxUNIT 5.pptx
UNIT 5.pptx
 
File Handling
File HandlingFile Handling
File Handling
 
File Handling
File HandlingFile Handling
File Handling
 
File Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingFile Management and manipulation in C++ Programming
File Management and manipulation in C++ Programming
 
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUSFILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
 
3.1 file input and output
3.1   file input and output3.1   file input and output
3.1 file input and output
 
VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5
 
File Handling in c++
File Handling in c++File Handling in c++
File Handling in c++
 
Python-files
Python-filesPython-files
Python-files
 
file_c.pdf
file_c.pdffile_c.pdf
file_c.pdf
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 

Mehr von Amandeep Kaur

Video/ Graphics cards
Video/ Graphics  cardsVideo/ Graphics  cards
Video/ Graphics cardsAmandeep Kaur
 
Menu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vbMenu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vbAmandeep Kaur
 
Image contro, and format functions in vb
Image contro, and format functions in vbImage contro, and format functions in vb
Image contro, and format functions in vbAmandeep Kaur
 
Data base connectivity and flex grid in vb
Data base connectivity and flex grid in vbData base connectivity and flex grid in vb
Data base connectivity and flex grid in vbAmandeep Kaur
 
Toolbar, statusbar, coolbar in vb
Toolbar, statusbar, coolbar in vbToolbar, statusbar, coolbar in vb
Toolbar, statusbar, coolbar in vbAmandeep Kaur
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphicsAmandeep Kaur
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphicsAmandeep Kaur
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphicsAmandeep Kaur
 
Report on browser war
Report on browser warReport on browser war
Report on browser warAmandeep Kaur
 
Report of internet connections
Report of internet connectionsReport of internet connections
Report of internet connectionsAmandeep Kaur
 
How to configure dns server(2)
How to configure dns server(2)How to configure dns server(2)
How to configure dns server(2)Amandeep Kaur
 

Mehr von Amandeep Kaur (20)

Video/ Graphics cards
Video/ Graphics  cardsVideo/ Graphics  cards
Video/ Graphics cards
 
Menu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vbMenu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vb
 
Active x control
Active x controlActive x control
Active x control
 
Image contro, and format functions in vb
Image contro, and format functions in vbImage contro, and format functions in vb
Image contro, and format functions in vb
 
Data base connectivity and flex grid in vb
Data base connectivity and flex grid in vbData base connectivity and flex grid in vb
Data base connectivity and flex grid in vb
 
Toolbar, statusbar, coolbar in vb
Toolbar, statusbar, coolbar in vbToolbar, statusbar, coolbar in vb
Toolbar, statusbar, coolbar in vb
 
Richtextbox
RichtextboxRichtextbox
Richtextbox
 
Treeview listview
Treeview listviewTreeview listview
Treeview listview
 
Progress bar
Progress barProgress bar
Progress bar
 
Socket
SocketSocket
Socket
 
Ppt of socket
Ppt of socketPpt of socket
Ppt of socket
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
 
Internet
InternetInternet
Internet
 
Internet working
Internet workingInternet working
Internet working
 
Report on browser war
Report on browser warReport on browser war
Report on browser war
 
Report of internet connections
Report of internet connectionsReport of internet connections
Report of internet connections
 
Report on intranet
Report on intranetReport on intranet
Report on intranet
 
How to configure dns server(2)
How to configure dns server(2)How to configure dns server(2)
How to configure dns server(2)
 

Kürzlich hochgeladen

How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17Celine George
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17Celine George
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17Celine George
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?TechSoup
 
UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and stepobaje godwin sunday
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptxSandy Millin
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRATanmoy Mishra
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice documentXsasf Sfdfasd
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxSaurabhParmar42
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationMJDuyan
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesMohammad Hassany
 

Kürzlich hochgeladen (20)

How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?
 
UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and step
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice document
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptx
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive Education
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming Classes
 

Filehandling

  • 1. Presentation on File Handling
  • 2. Contents  Definition Of File  Types Of Files  Operations on File  Opening A File  Closing A File  Writing Data To A File  Reading Data From A File  Detecting The End of File  Storing A File  Demo Application
  • 3. Definition Of File  A File is a collection of data stored on a computer’s disk.  Information can be saved to files and later reused.
  • 4. Types Of Files  There are three types of files. 1) Sequential Access Files 2) Random Access Files 3) Binary Files
  • 5. Sequential Access File  A sequential access file is a stream of data that must be read from its beginning to its end.  To read a record that is stored in the middle or at the end of sequential access file an application must read all the records in the file before it.
  • 6. Random Access File  In Random access file Records must be identical in length and may be accessed in any order.  An application may immediately jump to any record in a random access file without first reading the preceding records.
  • 7. Binary File  In binary file data is stored in binary form not in plain text.  The records in binary files may vary in length.  Binary files are usually smaller than text files but user cannot view their contents with text editor.
  • 8. Binary File  In binary file data is stored in binary form not in plain text.  The records in binary files may vary in length.  Binary files are usually smaller than text files but user cannot view their contents with text editor.
  • 10. File Open Mode Input Used with sequential acess file. Data will read from the files. Output Used with sequential access files . Data will be written to the file. Append Used with a sequential access file. Data will be written to the end of the file. Random This file is opened for random access . If the file does not exist,it is created. Binary The file is opened in binary mode. If the file does not exist , it is created .
  • 11. Opening A File  Open statement is used to open a file. Syntax : Open*filename*for mode as # filenumber [len=recordlength]
  • 12. Contd..  When a sequential file is opened , visual basic creates a file buffer.  A file buffer is a small holding section of memory that data is first written to.
  • 13. Closing A File  Close statement is used to close a file. Syntax : Close [filenumberlist] • In syntax, Filenumberlsit is one or more file numbers separated by commas.
  • 14. Contd..  The # symbol must appear with each file number.  Example close #1,#2  If user don’t specify any file number , visual basic closes all the files the applications has opened.
  • 15. Writing data to a File  Data may be written to a file that is opened in either output or append mode.  The write statement is used to write a data to the file. Syntax Write # filenumber, [itemlist]
  • 16. Reading data from a file  Data may be read from a file that already exist and is opened in input mode.  The input statement is used to read data from a file. Syntax Input # filenumber, itemlist
  • 17. Opening a file in append mode  When a file is opened in append mode data is written to the end of the file.  If the file is already exist its contents are not erased.  If the file does not exist it is created.
  • 18. Contd.. . Syntax Open filename for append as #1
  • 19. Detecting the end of the file  The EOF function detects when the end of file has been reached. Syntax EOF(file number) The function proves true if the end of file has been reached or false if the end of file has not been reached.
  • 22. How to apply picture on command button  Select the command button.  Draw it and then go to properties window.  Change the style property to 1-graphical.  Select the picture option.  Select the picture user want to apply.
  • 23. How to draw a shape •Select the shape option from the toolbox. •Then go to shape properties and select any option. Shape option
  • 24. Coding Of this Form  Private Sub cmdappend_Click()  Unload Me  frmappend.Show  End Sub  Private Sub cmdclose_Click()  Unload Me  End  End Sub
  • 25. Contd….  Private Sub cmdcreate_Click()  Unload Me  frmcreate.Show  End Sub  Private Sub cmdread_Click()  Unload Me  frmread.Show  End Sub  Private Sub cmdwrite_Click()  Unload Me  frmwrite.Show  End Sub
  • 27. Contd….  Dim fname As String  Dim productname As String  Dim companyname As String  Dim price As Integer  Dim intcount As Integer  Private Sub cmdclose_Click()  Unload Me  End  End Sub
  • 28. Contd….  Private Sub cmdcreate_Click()  fname = InputBox("Enter the File Name")  Open fname For Output As #1  For intcount = 1 To 4  MsgBox " Enter the product details " & FormatNumber(intcount, 0)  productname = InputBox("Enter the Product name")  companyname = InputBox("Enter the Company name")  price = Val(InputBox("Enter the Price"))  Write #1, productname, companyname, price  Next intcount  Close #1  End Sub
  • 29. Control Array  A control array is a group of controls all of the same type.  The control array has a name but the individual controls in the array donot.  To refer to a member of a control array, the syntax is:  ControlName(Index)[.Property]
  • 30. How to create a control array  Select (command button,text box ,label etc).  Then draw it.  Then copy it and paste it.  It will ask do you want to create a control array then click yes.
  • 33. Coding  Private Sub cmdappend_Click()  Open "d:aman.txt" For Append As #1  productname = "laptop"  companyname = "samsung"  price = 33000  Write #1, productname, companyname, price  Close #1  End Sub  Private Sub cmdclose_Click()  Unload Me  End  End Sub
  • 35. Coding  Private Sub cmdclose_Click()  Unload Me  End  End Sub  Private Sub cmdwrite_Click()  Open "d:aman.txt" For Output As #1  productname = "laptop"  companyname = "samsung"  price = 33000  Write #1, productname, companyname, price  Close #1  End Sub