SlideShare une entreprise Scribd logo
1  sur  36
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
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
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.
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
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
File Handling: Opening, Writing, Reading and Closing Files in Visual Basic

Contenu connexe

Tendances

Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm KristinaBorooah
 
L21 io streams
L21 io streamsL21 io streams
L21 io streamsteach4uin
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 
Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...Edureka!
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVAAnkita Totala
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams Ahmed Farag
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsAnton Keks
 
Java package
Java packageJava package
Java packageCS_GDRCST
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)Ritika Sharma
 
String and string buffer
String and string bufferString and string buffer
String and string bufferkamal kotecha
 

Tendances (20)

Data types in java
Data types in javaData types in java
Data types in java
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
Interface in java
Interface in javaInterface in java
Interface in java
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
 
Java package
Java packageJava package
Java package
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 

En vedette (20)

File handling
File handlingFile handling
File handling
 
File Handling in C++
File Handling in C++File Handling in C++
File Handling in C++
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
 
File handling in vb.net
File handling in vb.netFile handling in vb.net
File handling in vb.net
 
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++
 

Similaire à File Handling: Opening, Writing, Reading and Closing Files in Visual Basic

Similaire à File Handling: Opening, Writing, Reading and Closing Files in Visual Basic (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
 
ExplanationThe files into which we are writing the date area called.pdf
ExplanationThe files into which we are writing the date area called.pdfExplanationThe files into which we are writing the date area called.pdf
ExplanationThe files into which we are writing the date area called.pdf
 
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
 

Plus de 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
 

Plus de 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)
 

Dernier

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 

Dernier (20)

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

File Handling: Opening, Writing, Reading and Closing Files in Visual Basic

  • 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.
  • 21.
  • 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
  • 26.
  • 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.
  • 31.
  • 32.
  • 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
  • 34.
  • 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