Presentation is loading. Please wait.

Presentation is loading. Please wait.

ME 142 Engineering Computation I Variables, Equations & Functions Introduction to Basic Programming Language.

Similar presentations


Presentation on theme: "ME 142 Engineering Computation I Variables, Equations & Functions Introduction to Basic Programming Language."— Presentation transcript:

1 ME 142 Engineering Computation I Variables, Equations & Functions Introduction to Basic Programming Language

2 Key Concepts Defining Variables & Equations Launching VBA Programming Basics

3 Defining Variables & Equations

4 What is a Variable?

5 Variables  A named element that stores information or data  Variable examples: A=2.45 X=Y+Z I=I+1 B=“Hello Class”

6 Basic Math Operators  Same as used in Excel spreadsheets +add -subtract *multiply /divide ( )parenthesis ^exponent

7 Launching VBA

8 Enabling the Developer’s Ribbon

9 Launching VBA  Enable Developer’s Tab Once enabled, should remain enabled  Select Visual Basic from Developer’s Tab

10 Launching VBA  Right click on Project…  Select Insert/Module

11 Launching VBA Congratulations, you’re ready to begin programming!

12 Programming Basics

13 Example VBA Function Function demo(a,b)' (Input) 'An example program to add two numbers 'Add 2 numbers (Process) c = a + b 'Return results (Output) demo= c End Function

14 Executing a VBA Function

15 Saving a VBA Program  How do you save a program?  What is a macro-enabled workbook?  Where is the program saved?  How do I retrieve a program?  What is this error about macros that I get when I try to open my saved excel file?

16 Excel/VBA Tip  The VBA Function worksheetfunction may be used to call Excel function: P=worksheetfunction.pi D=worksheetfunction.degrees(x)

17 Example Problem  Develop a VBA function to calculate the volume of a sphere, given its radius, r. Volume = 4 * π * r 3 / 3  Use your new VBA function within Excel to find the total volume of the metal used to make the cannonball pyramid below, given d=4.5”

18 Review Questions

19 I-Clicker Question Variables Which of the following variable assignments are valid: A.x = y + z B.y + z = x C.Both are valid variable assignments D.Neither are valid variable assignments

20 I-Clicker Question Launching VBA The shortcut to launch the VBA editor is: A.Alt + V + B B.F7 C.Alt + F11 D.None of the above E.There is no shortcut

21 I-Clicker Question Running VBA In the first line of a function, the parenthesis immediately after the function name may be omitted: A.True B.False

22 Homework Help ‘n Hints


Download ppt "ME 142 Engineering Computation I Variables, Equations & Functions Introduction to Basic Programming Language."

Similar presentations


Ads by Google