Introduction to Engineering Computing GEEN 1300 Lecture 7 15 June 2010 Review for midterm.

Slides:



Advertisements
Similar presentations
1 Overview Introduction to VBA The Visual Basic Editor (VBE) –First Program Getting Started with VBA –Subroutines –Declaring variables –Input boxes and.
Advertisements

Using VB with MS Applications R. Juhl, Delta College.
Lecture 12: Spreadsheets for Engineering Applications - part 2
PROGRAMMING IN VISUAL BASIC PART 1
Object Oriented Programming A programming concept which views programs as objects with properties and ways to manipulate the object and the properties.
Visual Basic for Applications. What it does Extends the features and built in functions of Excel – Create and run VB procedures – Some may be easy to.
ELECTRONIC SPREADSHEATS ELECTRONIC SPREADSHEATS Chapter 14_Part2 Dr. Bahaa Al-Sheikh & Eng. Mohammed AlSumady Intoduction to Engineering BME152.
ENG 1181 College of Engineering Engineering Education Innovation Center Microsoft Excel: Data Analysis Trendlines Formulas Functions Cell Addressing.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Keith A. Woodbury Mechanical Engineering University of Alabama.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Programming in Visual Basic
Chapter 1 Computing Tools Data Representation, Accuracy and Precision Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 4 Programming and Software EXCEL and MathCAD.
First-Year Engineering Program 1 Autumn 2009 Graphing with Microsoft Excel Lecture 11 Engineering H191 Engineering Fundamentals and Laboratory.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Using the Visual Basic Editor Visual Basic for Applications 1.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 3 Programming and Software.
1 Introduction to Spreadsheets Bent Thomsen. 2 What is an electronic spreadsheet? It is the electronic equivalent of an accounting worksheet, comprised.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
Introduction to VBA. This is not Introduction to Excel We’re going to assume you have a basic level of familiarity with Excel If you don’t, or you need.
Lab 8 Solver In VBA ► Review – Solver Add-in In Excel ► Solver Add-in In VBA.
Lab 9 – User Forms Design. User Forms What are user forms? –Known as dialog boxes –Major ways for getting user input An example of using user forms: Monthly.
IE 212: Computational Methods for Industrial Engineering
Operations 343 Spreadsheet Modeling Week 15 Quiz Review Homework Review Course Review Lab session.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module M Programming in Excel with VBA.
University of Toronto at Scarborough © Andria Hunter, Kersti Wain-Bantin CSCA01 VBA-3 1 Lecture Outline Variable Scope Calling another subprogram Programming.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #4: Working with Variables and User Interfaces IE 212: Computational Methods for Industrial Engineering.
© McGraw-Hill Companies, Inc., McGraw-Hill/Irwin Extended Learning Module M Programming in Excel with VBA.
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
Introduction on VBA Lab 05 ins.Tahani Al_dweesh. Lab Objectives Introduction Calculation with VBA Storing and Retrieving Variables in a Worksheet Using.
Ch 11: Userforms CP212 Winter Topics Designing User Forms o Controls Setting Properties o Tab Order o Testing Writing Event Handlers o Userform_Initialize.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
® Microsoft Access 2010 Tutorial 11 Using and Writing Visual Basic for Applications Code.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
The Briefest Excel Tutorial You’ll Ever See. Microsoft Excel, or any spreadsheet for that matter, is an incredibly rich calculation program In this most.
Visual Basic for Applications Macro Programming For Microsoft Office.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 2.
ME 142 Engineering Computation I Debugging Techniques.
University of Sunderland CIF 102/FIF102 Fundamentals of DatabasesUnit 15 Programming in Microsoft Access using VBA Using VBA to add functionality.
Dialog Boxes – Day 1 Built-in Dialog Boxes Input Box Message Box Custom Dialog Boxes – User Forms.
Chapter 9 Macros And Visual Basic For Applications.
ME 142 Engineering Computation I Exam 2 Review VBA.
1 CS105 Discussion 5 – Variables and If Announcements MP 1 due on Monday Midterm 1 on Tuesday If you need a conflict, request it NOW!!
ME 142 Engineering Computation I Using Subroutines Effectively.
Chapter 11: Introduction to VBA Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Hungarian Notation A must in this course Every object used MUST be renamed including the form(s) using the following rules Form  frmFormName E.g. frmTemperature.
ME 142 Engineering Computation I Review Exam 1.  2 Part Exam In-Class Portion Testing Center Portion Equally weighted.
Controlling Program Flow with Decision Structures.
COMPREHENSIVE Access Tutorial 11 Using and Writing Visual Basic for Applications Code.
JavaScript 101 Lesson 6: Introduction to Functions.
CTS130 Spreadsheet Lesson 6 Working with Math & Trig, Statistical, and Date & Time Functions.
Lecture 6 – Working with VBA Sub Procedures Dr Joanna Wyrobek 1.
How to: Simple User Interface WMCUG 13 th Jan 2010 Gord Vander Vliet Enterprise Tool & Die, LLC Jeff Roark Johnson Controls.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
VBA Excel Macro 1.Create a Macro: To create a macro in Excel VBA, Create a Macro: To create a macro in Excel VBA,Create a Macro: To create a macro.
The Advantage Series ©2005 The McGraw-Hill Companies, Inc. All rights reserved Chapter 12 Introducing Visual Basic for Applications Microsoft Office Excel.
CS 106 Computing Fundamentals II Chapter 5 “Excel Basics for Windows”
CMPT 120 Topic: Python’s building blocks -> More Statements
Analyzing Data with Excel
Spreadsheet-Based Decision Support Systems
Microsoft Access Illustrated
Microsoft Office Illustrated
Microsoft Excel 2003 Illustrated Complete
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
Exploring Microsoft Excel
CS285 Introduction - Visual Basic
Spreadsheets and Data Management
Tutorial 11 Using and Writing Visual Basic for Applications Code
Presentation transcript:

Introduction to Engineering Computing GEEN 1300 Lecture 7 15 June 2010 Review for midterm

2 Double-click the Compute Re button. This will cause the following Sub wrapper to pop up in a code module: In here, we must add code to carry out the necessary calculations and display the Reynolds Number result Hooking VBA code to the “Compute Re” button…

3 This variable is the name you created for your textbox This is a variable you create and use in your calculation. Do NOT use the textbox name on the LHS of your calculation – it will not work!!

4 How to run and remove user forms insert a new module and add this Sub to start the UserForm double-click the Quit button and add the code to remove (“unload”) the UserForm run the StartReynoldsNumber macro… …and enter values with units selected

5 UserForms UserForms can be loaded automatically when the workbook is opened. (This is called an “event handler.”) And they can also be unloaded automatically when the workbook is closed. 1.Go to VBE and double click on thisworkbook item in Project Explorer. (If Project Explorer doesn’t show up, use view) 2. Change left field at top from General to Workbook. 3. Type in ReynoldsNumber.Show (this is not on any exam; it’s just a useful FYI)

6 Things to Remember!!! Create your own variables to carry out calculations, NOT the variables in the user form Make sure the variables from the user form that you assign to your created variables are the same names as in your user form These variables are those used from your text boxes and your option buttons, NOT your labels You should not have the same name for your text box as for your label

7 This variable is the name you created for your option button FormatNumber – number of digits after the decimal point. Does not round.

8 If you get a Reynolds number of and the program says MsgBox(FormatNumber(Re,1)), what will the message box say? a)2134 b)2135 c) d) e)2134.4

9 MsgBox Function MsgBox(“prompt”,buttons,”title”,helpfile,context) optional

10 MsgBox Function MsgBox(“prompt”,buttons,”title”,helpfile,context) optional Button codes vbOKOnlyvbExclamation vbOKCancelvbInformation vbAbortRetryIgnorevbDefaultButton1 vbYesNoCancelvbDefaultButton2 vbYesNovbDefaultButton3 vbRetryCancelvbDefaultButton4 vbCriticalvbSystemModal vbQuestion

11 MsgBox Function Putting line breaks into the message displayed: MsgBox result is button clicked by user

Announcements: Midterm exam Thursday at 8am Open book Open notes Open Excel/VBE No cheat sheet (duh) No collaboration

13 What the exam looks like: Excel: Displaying data (surface plots, creating xy grids) Fitting a model to a set of data points How good is the model overall? How good are the coefficients? Transforming equations to regression-friendly forms

14 What the exam looks like: VBE: Defining functions for use in spreadsheet Defining subs to manipulate spreadsheet Tracing through a function or sub (control flow) Calling a sub or function from another sub Fixing functions or subs with bugs Making a UserForm

15 How to study: Review all lecture notes Review all lab & homework problems Re-read any textbook sections & lecture notes that you need in order to fill in or clarify any shaky/fuzzy topics Think about Excel/VBA strengths & weaknesses and/or come to help hours with any questions

16 Excel syntax Precedence order, parentheses Cell references & cell addressing Formula copy How to translate equations & word statements to/from Excel Plotting Different types of models: Building them (see next slides) Evaluating them (R 2 & co.) Using them

17 Trendline & data regression What does each one do? What’s the difference between them? Which one do you use for what kind of problem? What do you feed into them and what do they return? How to transform equations so that these tools will work on them (also know when to do that and when you can’t) How to fit linear models if you don’t have these tools?

18 Excel, cont.: Goal Seek & Solver What does each one do? What’s the difference between them? Which one do you use for what kind of problem? What do you feed into them and what do they return?

19 Excel, cont.: Matrices Matrix math in Excel: naming, addition, subtraction, scaling, multiplication, inverse, determinant, transpose The identity matrix Systems of linear equations: How they correspond to matrix problems How to translate sets of linear equations to/from the equivalent matrix equation How to solve that matrix equation

20 Excel, cont.: Iteration How & when to use iteration Bisection What it does (including what a root is) How the algorithm works How to implement it in Excel

21 VBA: The environment VBA “world” & Excel “world” The VBE Modules: what they are & how you insert them The debugger: How you use it What it lets you find out How that’s different between Subs & Functions

22 VBA, cont.: Basic Syntax Write/evaluate VBA statements Know the basic functions (arithmetic, logic, relational) Understand the precedence rules Subs & Functions Know the differences Know how to write & use both

23 VBA, cont.: Decisions Know how to decode them and how to write them Including working with logical and relational operators Loops Know how all five loop structures work Be able to write one for a prescribed task Be able to figure out what a given loop will produce Flowcharts Be able to translate simple flowcharts to/from code

24 VBA, cont.: Modular programming Variables When, why, & how do you declare variables? When should you use different kinds of variables? Scoping Dialog boxes MsgBox & InputBox Understand them and use them User forms