19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

228 <strong>Computer</strong> <strong>Programming</strong> <strong>Concepts</strong> <strong>and</strong> <strong>Visual</strong> <strong>Basic</strong><br />

If Not EOF(1) Then<br />

Input #1, newMonth, dayNum, address, price<br />

Else<br />

doneFlag = True ‘End of list<br />

End If<br />

If (newMonth currentMonth) Or (doneFlag) Then ‘Control break processing<br />

If currentMonth “” Then ‘Don’t print subtotal before 1st month<br />

picReport.Print<br />

picReport.Print Tab(15); “Subtotal for “; currentMonth; “:”;<br />

picReport.Print Tab(38); FormatCurrency(monthTotal)<br />

picReport.Print<br />

End If<br />

currentMonth = newMonth<br />

monthTotal = 0<br />

End If<br />

If Not doneFlag Then<br />

picReport.Print newMonth;<br />

picReport.Print Tab(11); FormatNumber(dayNum, 0);<br />

picReport.Print Tab(18); address;<br />

picReport.Print Tab(38); FormatCurrency(price)<br />

yearTotal = yearTotal + price<br />

End If<br />

monthTotal = monthTotal + price<br />

Loop<br />

Close #1<br />

picReport.Print “Total for First Quarter: “; FormatCurrency(yearTotal)<br />

End Sub<br />

COMMENTS<br />

1. In the examples of this <strong>and</strong> the previous section, the files to be processed have<br />

been opened <strong>and</strong> closed within a single procedure. However, the solution to<br />

some programming problems requires that a file be opened just once the instant<br />

the program is run <strong>and</strong> stay open until the program is terminated. This is easily<br />

accomplished by placing the Open statement in the Form_Load event procedure<br />

<strong>and</strong> the Close <strong>and</strong> End statements in the click event procedure for a comm<strong>and</strong><br />

button labeled “Quit.”<br />

7.3 A CASE STUDY: RECORDING CHECKS AND<br />

DEPOSITS<br />

The purpose of this section is to take you through the design <strong>and</strong> implementation of a quality<br />

program for personal checkbook management. Nothing in this chapter shows off the power<br />

of <strong>Visual</strong> <strong>Basic</strong> better than the program in this section. That a user-friendly checkbook management<br />

program can be written in less than five pages of code clearly shows <strong>Visual</strong> <strong>Basic</strong>’s<br />

ability to improve the productivity of programmers. It is easy to imagine an entire finance<br />

program, similar to programs that have generated millions of dollars of sales, being written in<br />

only a few weeks by using <strong>Visual</strong> <strong>Basic</strong>!<br />

■ THE DESIGN OF THE PROGRAM<br />

Though there are many commercial programs available for personal financial management, they<br />

include so many bells <strong>and</strong> whistles that their original purposes—keeping track of transactions

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!