Presentation is loading. Please wait.

Presentation is loading. Please wait.

Saving and Accessing Data

Similar presentations


Presentation on theme: "Saving and Accessing Data"— Presentation transcript:

1 Saving and Accessing Data

2 Two general ways to save data
To an established file format, like MS Access or Excel. That is the most common way. To a file that you define (dat, txt, etc.): Sequential Random Binary

3 File differences Sequential Read/Write the WHOLE file
Random Read/Write any Record Binary Read/Write any Byte

4 Opening Files Read Write Both Open “theFile.txt” as #1
Now refer to theFile.txt as #1 The # is the “channel” of the file You can find a FreeFile.

5 You open with the following modes:
Append Binary Output Random Adds to end of sequential file Write/Read individual Bytes Write/Overright sequential file Write to specific Records Random is the Default Open “myFile.txt” for Random as #3

6 Managing Multiple Users
Access Restriction Write Read Write Read LockType Shared Lock Read Lock Write Lock Read Write Open "C:\Random.txt" For Random Access Read Write Shared As #intFile Len = 5 Book is not clear on Access. These are needed when multiple users are involved to maintain file integrity.

7 Length -- Len Necessary with random files to let the computer know how far to look for the next record. RECORD – One “line” or set of information. Examples: Each recipe in a cookbook; Each entry in an address book.

8 Input/Output Choices To File From File
Sequential (Append, Input, Output) Print # Write # Read # Random Put # Get # Put #7, recordNum, Variable

9 Delimeters Delimeters are characters that indicate the end of a “column” or “field” A column or field is one variable in a record. Kevin, Harville, Instructor, Joe, Jones, Dog Catcher,

10 Record Lengths Kevin Harville Instructor Joe Jones Dog Catcher
Establishing data lengths helps the computer know where to look for the information

11 Data Types Data Types are like a master variable with sub-variables.
Employee.Age Employee.FirstName Employee.LastName Employee.SSN

12 Data Types Declare in Modules Type Employee
strFName As String * 10 strLName As String * 16 strSSN As String * 12 End Type Dim Worker(100) As Employee Worker(x).strFName=strInputName Worker(x).strLName=strInputLName Worker(x).strSSN=txtSSN.Text

13 File Controls File List Box Drive List Box Directory List Box
You need to program functionality in these or the common dialog box to manually access files

14 File Commands Chdrive ChDir Kill MkDir RmDir Dir

15 Changing Usual place to responde to changes is in the Change event of the directory, file, or drive controls. ChDrive drvDisk.Drive ChDir dirDirect.Path FilFiles.Pattern= “*.txt; *.htm”


Download ppt "Saving and Accessing Data"

Similar presentations


Ads by Google