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.

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

Private Sub TotalExpenses(etot() As Single)<br />

Dim row As Integer, col As Integer<br />

‘Total expenses for each of four quarters<br />

For col = startCol To stopCol<br />

etot(col) = 0<br />

For row = expStartRow To expStopRow<br />

etot(col) = etot(col) + Val(txtCell(Indx(row, col)).Text)<br />

Next row<br />

txtCell(Indx(expTotRow, col)).Text = FormatNumber(etot(col), 0)<br />

Next col<br />

End Sub<br />

Private Sub TotalIncome(itot() As Single)<br />

Dim row As Integer, col As Integer<br />

‘Total income for each of four quarters<br />

For col = startCol To stopCol<br />

itot(col) = 0<br />

For row = incStartRow To incStopRow<br />

itot(col) = itot(col) + Val(txtCell(Indx(row, col)).Text)<br />

Next row<br />

txtCell(Indx(incTotRow, col)).Text = FormatNumber(itot(col), 0)<br />

Next col<br />

End Sub<br />

Private Sub TotalRows()<br />

Dim row As Integer, col As Integer, rowTot As Single<br />

‘Total each income category<br />

For row = incStartRow To incStopRow<br />

rowTot = 0<br />

For col = startCol To stopCol<br />

rowTot = rowTot + Val(txtCell(Indx(row, col)).Text)<br />

Next col<br />

txtCell(Indx(row, totCol)).Text = FormatNumber(rowTot, 0)<br />

Next row<br />

‘Total each expense category<br />

For row = expStartRow To expStopRow<br />

rowTot = 0<br />

For col = startCol To stopCal<br />

rowTot = rowTot + Val(txtCell(Indx(row, col)).Text)<br />

Next col<br />

txtCell(Indx(row, totCol)).Text = FormatNumber(rowTot, 0)<br />

Next row<br />

End Sub<br />

Private Sub txtCell_GotFocus(Index As Integer)<br />

Dim row As Integer, col As Integer<br />

‘Force focus into a data txtCell for this application<br />

row = Int((Index - 1) / maxCol) + 1<br />

col = ((Index - 1) Mod maxCol) + 1<br />

If col > stopCol Then<br />

row = row + 1<br />

col = startCol<br />

End If<br />

If row < incStartRow Then

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

Saved successfully!

Ooh no, something went wrong!