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.

Dim message As String<br />

‘If one of the four required pieces of information<br />

‘is missing, assign its name to message<br />

message = “”<br />

If txtDate.Text = “” Then<br />

message = “Date”<br />

txtDate.SetFocus<br />

ElseIf txtToFrom.Text = “” Then<br />

If transType = “Check” Then<br />

message = “Pay To”<br />

Else<br />

message = “Source”<br />

End If<br />

txtToFrom.SetFocus<br />

ElseIf txtAmount.Text = “” Then<br />

message = “Amount”<br />

txtAmount.SetFocus<br />

ElseIf txtNum.Text = “” Then<br />

If transType = “Check” Then<br />

message = “Check Number”<br />

Else<br />

message = “Deposit Number”<br />

End If<br />

txtNum.SetFocus<br />

End If<br />

If message = “” Then<br />

‘All required data fields have been filled; recording can proceed<br />

AllDataGiven = True<br />

Else<br />

‘Advise user of required data that are missing<br />

MsgBox “The ‘” & message & “ ‘field must be filled”, , “Error”<br />

AllDataGiven = False<br />

End If<br />

End Function<br />

Private Sub cmdMode_Click()<br />

‘Toggle from Check to/from Deposit Slip<br />

If transType = “Check” Then<br />

Call SetupDeposit<br />

Else ‘transType = “Deposit”<br />

Call SetupCheck<br />

End If<br />

Call InitializeFields<br />

txtToFrom.SetFocus<br />

End Sub<br />

A Case Study: Recording Checks <strong>and</strong> Deposits 233<br />

Private Sub cmdPrint_Click()<br />

Dim temp As String, lineNo As Integer<br />

Dim nameOnChk As String, balance As Single, ck As Integer, dp As Integer<br />

Dim toFrom As String, amount As String, memo As String, theDate As String<br />

‘Print out a detailed list of all transactions.<br />

temp = frmCheckbook.Caption ‘Save the current form caption<br />

frmCheckbook.Caption = “Printing...” ‘Set form caption to indicate printing<br />

lineNo = 1 ‘Line number being printed<br />

Open fileName For Input As #1 ‘Open the file<br />

Input #1, nameOnChk, balance, ck, dp ‘Read in the file header

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

Saved successfully!

Ooh no, something went wrong!