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.

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

Next row<br />

‘Create Row Labels<br />

For row = 2 To maxRow<br />

Load lblRowLab(row)<br />

lblRowLab(row).Top = lblRowLab(row - 1).Top + cellHeight<br />

lblRowLab(row).Caption = LTrim(Str(row))<br />

lblRowLab(row).Visible = True<br />

Next row<br />

‘Create Column Labels<br />

For col = 2 To maxCol<br />

Load lblColLab(col)<br />

lblColLab(col).Left = lblColLab(col - 1).Left + cellWidth<br />

lblColLab(col).Caption = Chr(col + 64)<br />

lblColLab(col).Visible = True<br />

Next col ‘Set form height <strong>and</strong> width to accommodate all objects<br />

i = Indx(maxRow, maxCol)<br />

frmSpreadsheet.Height = txtCell(i).Top + cellHeight + 500<br />

frmSpreadsheet.Width = txtCell(i).Left + cellWidth + 200<br />

End Sub<br />

Private Sub DisplayTotals()<br />

ReDim itot(startCol To stopCal) As Single<br />

ReDim etot(startCol To stopCal) As Single<br />

‘Calculate <strong>and</strong> show totals for Income each quarter<br />

Call TotalIncome(itot())<br />

‘Calculate <strong>and</strong> show totals for Expenses each quarter<br />

Call TotalExpenses(etot())<br />

‘Calculate <strong>and</strong> show Balances for each quarter<br />

Call ShowBalances(itot(), etot())<br />

‘Calculate <strong>and</strong> show the Total of each Income & Expense category<br />

Call TotalRows<br />

‘Calculate <strong>and</strong> show gr<strong>and</strong> totals of quarter totals <strong>and</strong> balances<br />

Call ShowGr<strong>and</strong>Totals(itot(), etot())<br />

End Sub<br />

Private Sub Form_Load()<br />

‘Establish number of rows <strong>and</strong> columns. Trial <strong>and</strong> error show<br />

‘that a maximum of 20 rows <strong>and</strong> 8 columns will fit the screen.<br />

‘For this particular application, 16 rows <strong>and</strong> 6 columns are adequate.<br />

maxRow = 16<br />

maxCol = 6<br />

Call CreateSpreadsheet<br />

Call SetStructure<br />

Call SetDefaults<br />

End Sub<br />

Private Function Indx(row As Integer, col As Integer) As Integer<br />

Indx = (row - 1) * maxCol + col<br />

End Function<br />

Private Sub SetDefaults()<br />

‘Set default values specific to this application<br />

txtCell(Indx(3, 1)).Text = “Job”<br />

txtCell(Indx(4, 1)).Text = “Parents”<br />

txtCell(Indx(5, 1)).Text = “Scholarship”<br />

txtCell(Indx(9, 1)).Text = “Tuition”

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

Saved successfully!

Ooh no, something went wrong!