Outline Software and Programming Program Structure Tools for Designing Software Programming Languages Introduction to Visual Basic (VBA)

Slides:



Advertisements
Similar presentations
Sep-05 Slide:1 VBA in Excel Walter Milner. Sep-05 Slide:2 VBA in Excel Introduction VBA = Visual Basic for Applications Enables end-user programming In.
Advertisements

CE 311 K Introduction to Computer Methods VB Controls and Events Daene C. McKinney.
VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming.
Using Macros and Visual Basic for Applications (VBA) with Excel
Some computer fundamentals and jargon Memory: Basic element is a bit – value = 0 or 1 Collection of “n” bits is a “byte” Collection of several bytes is.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Fundamentals of Programming in Visual Basic
CVEV 118/698 Visual Basic Lecture 1 Prof. Mounir Mabsout Expert 1: Elsa Sulukdjian Expert 2: Walid El Asmar.
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Introduction to Visual Basic What it is, and a simple program Mike Thelwall University of Wolverhampton, UK.
VB Code Statements 3 types of VB statement The Remark statement, known as comments, are used for project documentation only Begin with an apostrophe Not.
To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window.
Access VBA Programming for Beginners - Class 1 - by Patrick Lasu
Christopher Guertin VAMC – West Palm Beach, FL 1.
Variables, Constants, Methods, and Calculations Chapter 3 - Review.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Not in Text CP212 Winter No VBA Required “Regular” Programming traditional programming is sequential in nature o one command executed after another.
Visual Basic Chapter 1 Mr. Wangler.
Unit 20: Event Driven Programming
Languages and Environments Higher Computing Unit 2 – Software Development.
CS 0004 –Lecture 1 Wednesday, Jan 5 th, 2011 Roxana Gheorghiu.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #4: Working with Variables and User Interfaces IE 212: Computational Methods for Industrial Engineering.
Tutorial 11 Using and Writing Visual Basic for Applications Code
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Lab 01 Forms in excel Tahani ALdweesh Insert form into your project. 2. Change form’s properties. 3. Put controls on the form. 4. Change controls’
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 1 Copyright © 2008 Prentice-Hall. All rights reserved. What Can I Do with a Spreadsheet.
Input, Output, and Processing
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Access VBA Programming for Beginners - Class 2 - by Patrick Lasu
Chapter 2: Using Data.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
Visual Basic IITG to be expanded. What is Visual Basic? Object Oriented Programming Language (OOP) Graphical User Interface (GUI) Event Driven – Write.
University of Sunderland CIF 102/FIF102 Fundamentals of DatabasesUnit 15 Programming in Microsoft Access using VBA Using VBA to add functionality.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Items in Visual Basic programs
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
I Power Higher Computing Software Development Development Languages and Environments.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
ME 142 Engineering Computation I Using Subroutines Effectively.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
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.
Chapter 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
COMPREHENSIVE Access Tutorial 11 Using and Writing Visual Basic for Applications Code.
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
VBA - Excel VBA is Visual Basic for Applications
An Introduction to Computers and Visual Basic
An Introduction to Computers and Visual Basic
Variables and Arithmetic Operations
VISUAL BASIC.
CS285 Introduction - Visual Basic
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 1/15/2019.
An Introduction to Computers and Visual Basic
Introduction to Programming
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 7/9/2019.
Presentation transcript:

Outline Software and Programming Program Structure Tools for Designing Software Programming Languages Introduction to Visual Basic (VBA)

ENGR 112 Programming Languages

Types of Programming Procedural Strict sequence of processing steps Distinct start/stop points in program #include main() { printf("Content-type: text/html\n\n"); printf(" "); printf("Hello World!"); printf(" "); }

Types of Programming Event-Driven Waits for an “event” to trigger program execution Modular programming No start/stop point in program

Types of Programming Event-Driven

Private Sub cmbDates_Click() Me.txtSSNScanned.SetFocus Call scanSSN End Sub Private Sub cmdEndProgram_Click() If endProgram Then End Else endProgram = False End If End Sub Private Sub txtSSNScanned_GotFocus() If Me.cmbDates.Text = "" Then MsgBox ("You need to enter a date!") Me.cmbDates.SetFocus Exit Sub End If End Sub Procedure #2 Procedure #3 Procedure #1

Programming Languages Assembly Language Fast and most efficient Very difficult to program in Basic Beginner’s All-purpose Symbolic Instruction Code Easy to use Lacks total control

Programming Languages Fortran FORmula TRANslator Great for mathematical programming Not good for other uses, e.g. graphics C and C++ Powerful tools Harder to use/learn than BASIC Can do anything

Programming Languages Visual Basic Develop windows programs easily Powerful tool Not as much control as Visual C VBA (Visual Basic for Applications) Visual C and C++ Develop windows applications Not easy to learn

VBA Macro Programming VBA is a general purpose programming language that comes standard with Excel or Office. Using VBA with Excel, powerful engineering analysis tools can be developed quickly and with minimum cost. VBA can be used for many engineering tasks communicating with engineering databases analyzing engineering data automating worksheet construction engineering modeling and simulation creating charts and engineering wizards (i.e. dialog boxes) creating GUI's

Advantages of VBA Programmer does not need to be an expert Windows programmer Programmer creates GUI and defines what happens when user interacts with it Events are generated Push a button, move mouse, etc. This is called event-driven programming

Visual Basic Overview Objects Events Numbers Strings Variables Operators

Elements of a Visual Basic Objects & Events Label Text box Picture box (text) Picture box (image) Command button

Object Properties The most important properties (at least for the purpose of this course) are: Name (object’s name – important!!) Caption (text to be displayed by the object) Font (what the text looks like) Visible (how it links to other applications)

Objects With Names lblEngr112 txtInputA, txtInputB picResults picCOE cmdAddButton

Visual Basic Events Change initiated by user Load a Form Click on a button Mouse down/up, Mouse drag Key down, key press, etc. Causes an event procedure (subprogram) to execute

Elements of Visual Basic Data Constants (data that does not change) Numbers (e.g., ) Strings (e.g., “this is a string”) Variables (names of data holders) Numbers Strings Operators Arithmetic (+, -, *, /, etc.) String (&)

Visual Basic Integers Sequence of digits with no Commas Decimal points Negative numbers preceded by ‘-’ Positive numbers optionally preceded by ‘+’

Single Precision Real Numbers Standard Representation Integer (whole number) portion Decimal point Unsigned integer (fractional) portion

Visual Basic Strings String: Sequence of characters (a, b, c,..., 0, 1, 2,..., ~, !,...) treated as a unit Enclosed in double quotes in VB statement “this is a string” “John Smith” “ ” “a + b = “

Visual Basic Variables Variable Symbolic name for data value Name of data “holder” Name of a location in random access memory Variable names rules Must begin with a letter May contain only letters, digits, and underscores (_) Up to 255 characters long

Variable Names a, b, c,..., x, y, z distance, speed, time, average rateOfIncrease, startingTime, hoursPerWeek rate_of_increase, starting_time, hours_per_week

Declaring Variable Types Two options Implicit declaration Explicit declaration Dim name As String Dim count As Integer Dim average As Single Dim nextItem As Variant Explicit declaration is always preferable!!

VB Arithmetic Operators Addition (+) a + b Subtraction (-) a - b Multiplication (*) a * b Division (/) a / b Exponentiation (^) a ^ b

Arithmetic Order of Evaluation 1. Exponentiation (R - L) 2. Multiplication & division (L-R) 3. Addition & subtraction (L-R)

Examples of Evaluation (1) * *

Converting Formulas to VB 1 a + b 1c1c 1d1d efef ghgh (1.0 / (a + b)) ^ 2 / ((1.0 / c / d) * (e / f - g / h))

String Operator Concatenation (&) “good” & “bye” “goodbye”