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.

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

EXAMPLE 2<br />

The following program creates a simplified spreadsheet. The user places a number into the active cell by<br />

typing the number into an input box. The program keeps a running total of the sum of the numbers.<br />

‘In (Declarations) section of (General)<br />

Dim numRows As Integer ‘number of rows<br />

Dim numCols As Integer ‘number of columns<br />

Object Property Setting<br />

frmSprdSht Caption Spreadsheet<br />

lblAdjust Caption Adjust<br />

cmdRows Caption Rows<br />

cmdCols Caption Columns<br />

cmdQuit Caption Quit<br />

lblMsg Caption Click on a cell to<br />

change its value<br />

msgSprdSht ScrollBars 0 – flexScrollBarNone<br />

FixedRows 0<br />

FixedCols 0<br />

Font Courier New<br />

Private Sub cmdRows_Click()<br />

Dim temp As String<br />

‘Adjust the number of rows in the spreadsheet<br />

temp = InputBox(“Enter new number of rows (4-24):”)<br />

If (Val(temp) >= 4) And (Val(temp) < Then<br />

numRows = Val(temp)<br />

Call SetUpGrid<br />

Call ShowValues<br />

Call ShowTotals<br />

End If<br />

End Sub<br />

Private Sub cmdCols_Click()<br />

Dim temp As String<br />

‘Adjust number of columns in the spreadsheet<br />

temp = InputBox(“Enter new number of columns (2-7):”)<br />

If (Val(temp) >= 2) And (Val(temp)

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

Saved successfully!

Ooh no, something went wrong!