• Home
  • Textbooks
  • Microsoft Visual Basic Programs to Accompany Programming Logic and Design
  • File Handling and Applications

Microsoft Visual Basic Programs to Accompany Programming Logic and Design

Jo Ann Smith

Chapter 7

File Handling and Applications - all with Video Answers

Educators


Section 1

Opening Files and Performing File Input

Problem 1

In this exercise, you use what you have learned about opening a file and getting input into a program from a file. Study the following code, and then answer Questions 1-3.
$$
\begin{array}{|ll|}
1 & \text { FileOpen(1, myDvdFile.dat, OpenMode.Output) } \\
2 & \text { Dim dvdName As String } \\
3 & \text { Dim dvdPrice As String } \\
4 & \text { Dim dvdShelf As String } \\
5 & \text { Input(1,dvdName) } \\
6 & \text { Input(1,dvdPrice) } \\
7 & \text { Input(1,dvdShe1f) }
\end{array}
$$
There are two errors on line 1. Describe the first error, and explain how to fix it.

Check back soon!

Problem 2

In this exercise, you use what you have learned about opening a file and getting input into a program from a file. Study the following code, and then answer Questions 1-3.
$$
\begin{array}{|ll|}
1 & \text { FileOpen(1, myDvdFile.dat, OpenMode.Output) } \\
2 & \text { Dim dvdName As String } \\
3 & \text { Dim dvdPrice As String } \\
4 & \text { Dim dvdShelf As String } \\
5 & \text { Input(1,dvdName) } \\
6 & \text { Input(1,dvdPrice) } \\
7 & \text { Input(1,dvdShe1f) }
\end{array}
$$
Describe the second error on line 1, and explain how to fix it.
$\qquad$

Check back soon!

Problem 3

In this exercise, you use what you have learned about opening a file and getting input into a program from a file. Study the following code, and then answer Questions 1-3.
$$
\begin{array}{|ll|}
1 & \text { FileOpen(1, myDvdFile.dat, OpenMode.Output) } \\
2 & \text { Dim dvdName As String } \\
3 & \text { Dim dvdPrice As String } \\
4 & \text { Dim dvdShelf As String } \\
5 & \text { Input(1,dvdName) } \\
6 & \text { Input(1,dvdPrice) } \\
7 & \text { Input(1,dvdShe1f) }
\end{array}
$$
Assuming the errors in line 1 are corrected, consider the following data from the input file myDvdFile.dat:
Lost, $35.00,1 \mathrm{~A}$
Watchmen, 29.00, 2C
Heroes, $39.00,3 B$
a. What value is stored in the variable named dvdName?
$\qquad$
b. What value is stored in the variable name dvdPrice?
$\qquad$
c. What value is stored in the variable named dvdShelf?
$\qquad$

Check back soon!