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.

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

‘Set name <strong>and</strong> balance labels<br />

lblName.Caption = nameOnChk<br />

lblBalance.Caption = FormatCurrency(curBal)<br />

‘Set the date field to the current date<br />

today = FormatDateTime(Now, vbLongDate)<br />

txtDate.Text = Mid(today, 2 + InStr(today, “,”))<br />

Call SetupCheck ‘Always start session with checks<br />

Call InitializeFields<br />

End Sub<br />

Private Sub InitializeFields()<br />

‘Initialize all text entry fields except date<br />

txtToFrom.Text = “” txtAmount.Text = “”<br />

txtMemo.Text = “”<br />

If transType = “Check” Then<br />

‘Make txtNum text box reflect next check number<br />

txtNum.Text = Str(lastCkNum + 1)<br />

Else ‘transType = “Deposit”<br />

‘Make txtNum text box reflect next deposit slip number<br />

txtNum.Text = Str(lastDpNum + 1)<br />

End If<br />

End Sub<br />

Private Sub ReadDataFile()<br />

Dim t As String, s As String, n As String, m As String, d As String<br />

‘Recover name to appear on checks, current balance,<br />

‘number of last check written, <strong>and</strong> number of last deposit slip processed<br />

Open fileName For Input As #1<br />

Input #1, nameOnChk, curBal, lastCkNum, lastDpNum<br />

Do Until EOF(1)<br />

‘Read to the end of the file to recover the current balance <strong>and</strong> the<br />

‘last values recorded for ckNum <strong>and</strong> dpNum.<br />

‘t, s, n, m <strong>and</strong> d are dummy variables <strong>and</strong> are not used at this point<br />

Input #1, t, s, curBal, lastCkNum, lastDpNum, n, m, d<br />

Loop<br />

Close #1<br />

End Sub<br />

Private Sub SetupCheck()<br />

‘Prepare form for the entry of a check<br />

transType = “Check”<br />

frmCheckbook.Caption = “Check”<br />

lblToFrom.Caption = “Pay To”<br />

cmdRecord.Caption = “&Record This Check”<br />

cmdMode.Caption = “&Switch to Deposits”<br />

picBox.BackColor = vbCyan ‘color of check is light turquoise blue<br />

txtNum.BackColor = vbCyan<br />

End Sub<br />

Private Sub SetupDeposit()<br />

‘Prepare form for the entry of a deposit<br />

transType = “Deposit”<br />

frmCheckbook.Caption = “Deposit Slip”<br />

lblToFrom.Caption = “Source”

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

Saved successfully!

Ooh no, something went wrong!