Subroutines and functions parameters aka arguments Debugging interactive source

Subroutines and functions parameters aka arguments

This preview shows page 28 - 34 out of 49 pages.

Subroutines and functionsparameters (aka arguments)Debugginginteractive source-level debuggingLook these up in “Computer Conuence (5/e)” or talk to usif you’ve forgotten some of these, didn’t take CS 100, etcRelevant Programming Concepts from CS 100Friday, October 12, 2012
Background image
CS 200 Fall 2012Excel ScriptingThings We Still Need to Talk About To Do The Assignment“Objects” in Excel — how to name objects on a spreadsheet& the Object Browser, which documents them“Named Parameters” in ExcelExcel’s debuggerConveniently triggering macro executionCell referencesin worksheetsin macros24Friday, October 12, 2012
Background image
CS 200 Fall 2012Excel Scripting“Objects” in Excel MacrosJust about everything you see in a workbook is an “object”There is a natural hierarchy to objectsYou can have multiple instancesof everything except the ApplicationThese are Excel’s “application data objects”(remember the Model pearl?)A “module” is for holding macros (aka “scripts”)think of it as a documentcontaining multiple macro definitionsin the VBE: Insert > Module and typeor ... a module is created automaticallywhen you record a macro25ApplicationWorkbookWorksheetRangeRangeChartModuleCellCellCellSee Chapter 5 of The Microsoft Excel Visual Basic User’s Guideon “Working with Objects in Visual Basic” (pp 65–84),which is reprinted in the course notes, for more on objects in Excel.Friday, October 12, 2012
Background image
CS 200 Fall 2012Excel ScriptingObjectsObjects have “properties” like “Color,” “Value,” “Font”that you can read or set in macros sometimes a property is just a value (eg 2)sometimes a property is another objectObjects have “methods” like “ClearContents,” “Sort,” “Worksheets”that cause something to be done to or with the objecta “method” is just another kind of built-in function or subroutinethat does something to or with the object it’s attached tomethods often have “parameters” (aka “arguments”)— information they need— just like built-in Excel functionseg C4, ForEx, and 2 in VLOOKUP( C4, ForEx, 2 )“Member” is programmer-speak for both properties and methodsAll objects of a particular kind are a “class” of objects26Friday, October 12, 2012
Background image
CS 200 Fall 2012Excel ScriptingReferring to an object or propertyReferring to an object or propertyEG: Application.Worksheets("Visa") _.Range("Stmt").Font.Name = "Helvetica"HereApplication is an objectWorksheets() is a method (that returns a Worksheet object)Range() is a method (that returns a Range object)Font is a property (whose value is a Font object)Name is a property (a string)The () surround a method’s parameters — information the method needs to do its thing.You can use the Properties Windowto set an object’s properties manually27TFriday, October 12, 2012
Background image
CS 200 Fall 2012Excel ScriptingReferring to an object or propertyReferring to an object or propertyEG: Application.Worksheets("Visa") _.Range("Stmt").Font.Name = "Helvetica"HereApplication is an objectWorksheets()
Background image
Image of page 34

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture