File Processing Creating Reading Text Files Storing Data
- Slides: 10
File Processing Creating & Reading Text Files
Storing Data in Text Files: With VB 2008 �File>New Project>Windows. Form. Application �(provide a project name) �Highlight project name in Solution Explorer. �Add>New Item �Select Text File icon> provide name �Type in data values, one per line �Save All 2
Data for text file: Payroll. txt Sandy Kinnery 9. 35 35 Judy Mollica 10. 75 33 3
Problem: Calculate Payroll 4
Syntax to Read in Data Sequentially from File Dim reader. Var As IO. Stream. Reader reader. Var = IO. File. Open. Text(filespec) Varname = reader. Var. Read. Line filespec must include the full pathname unless the file is in Project. Folder. Name/bin/Debug 5
Code In Button Click-Event Dim reader. Var As IO. Stream. Reader Dim str. Name As String Dim dec. Hourly. Wage As Decimal Dim dec. Hours. Worked As Decimal Dim dec. Salary As Decimal reader. Var = IO. File. Open. Text("Payroll. txt") 6
Read in Data from Text File str. Name = reader. Var. Read. Line dec. Hourly. Wage = CDec(reader. Var. Read. Line) dec. Hours. Worked = CDec(reader. Var. Read. Line) dec. Salary = dec. Hourly. Wage * dec. Hours. Worked 7
Display Results in a List. Box lst. Results. Items. Add(str. Name & " " & _ Format. Currency(dec. Salary)) reader. Var. Close() 8
Peek Method of Stream. Reader Class: Returns -1 when EOF �reader. Var = IO. File. Open. Text("Payroll. txt") Do While reader. Var. Peek <> -1 str. Name = reader. Var. Read. Line dec. Hourly. Wage = CDec(reader. Var. Read. Line) dec. Hours. Worked = CDec(reader. Var. Read. Line) dec. Salary = dec. Hourly. Wage * dec. Hours. Worked lst. Results. Items. Add(str. Name & " " & _ Format. Currency(dec. Salary)) Loop reader. Var. Close() 9
Text Readings �List. Box – pp. 294 -299 �Text Files – pp. 658 -671 �Not exactly what we’ve done today 10
- File mode python
- Cjis security awareness training should be conducted
- Cjis meaning
- File-file yang dibuat oleh user pada jenis file di linux
- Text to text text to self text to world
- Markup tag tells the web browser
- Fhand python
- While reading activities
- Evolution of file system data processing
- Outline steps to be taken when creating a sequential file
- Describing and storing data in dbms