CW-V1 SDD 0601 Principals of Software Design and Development Variables Constants Data Types Error Handling Starter: BlockbustersBlockbusters.

Slides:



Advertisements
Similar presentations
Ch. 3 Variables VB.Net Programming. Data Types Boolean – True or False values Short – Small integers (+/- 32,767) Integer – Medium-size integers (+/-
Advertisements

Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
String Variables Visual Basic for Applications 4.
Control Structures: Part 2. Introduction Essentials of Counter-Controlled Repetition For / Next Repetition Structure Examples Using the For / Next Structure.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.
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.
Copyright © 2001 by Wiley. All rights reserved. Chapter 3: Variables, Assignment Statements, and Arithmetic Variables Assignment Statements Arithmetic.
110-D1 Variables, Constants and Calculations(1) Chapter 3: we are familiar with VB IDE (building a form…) to make our applications more powerful, we need.
Apply Sub Procedures/Methods and User Defined Functions
Saeed Ghanbartehrani Summer 2015 Lecture Notes #4: Working with Variables and User Interfaces IE 212: Computational Methods for Industrial Engineering.
Visual Basic: An Object Oriented Approach 5: Structured Programming.
Learning about Expert Systems through computer programming.
 An object-oriented programming language ◦ Instructions for the manipulation of objects ◦ A structured way to provide instructions to Excel  Excel has.
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
Variables "There are 10 kinds of people in the world today – those who understand binary and those who don't!” Unknown.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Access VBA Programming for Beginners - Class 2 - by Patrick Lasu
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
20/10/ Working with Data Declaring Variables, Overflow.
Input Textboxes Input Boxes Different than textboxes Good for small amount of input (form full of textboxes is not nice) X = Inputbox(“prompt message”,
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
INT213 Week 1.  A Named storage area (in RAM) that can hold a value (like a mailbox holding a letter)  Contents of a variable can be assigned, changed.
27/05/ Iteration Loops Nested Loops & The Step Parameter.
1 Flow Control II Code: Select-Case and For-Next Controls: Frames and OptionButtons.
CS285 Visual Basic 2 Department of Computing UniS 1 Statements in Visual Basic A statement is the fundamental syntactical element of a program smallest.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
A Simple Guide to Using SPSS ( Statistical Package for the Social Sciences) for Windows.
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Applications Development
22/11/ Selection If selection construct.
Validation "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
CW-V1 SDD 0901 Principals of Software Design and Development Loops Starter: Water JugsWater Jugs.
Variable, Constants and Calculations Dr Mohammad Nabil Almunawar.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
Chapter 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
31/01/ Selection If selection construct.
Error Handling Tonga Institute of Higher Education.
Variables Continued In the last session we saw how variables are objects that allow us to store values in the RAM of the computer In this session we shall.
Higher Computing Software Development -So Far- 5/10/10.
Controlling Program Flow with Looping Structures
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
C OMPUTER P ROGRAMMING 1 Input and Variables. I/O S TATEMENTS : I NPUT & V ARIABLES Input is the term used to describe the transfer of information from.
Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?
Controlling Program Flow with Decision Structures.
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
Paper 2 Exam Tips Guidance: 1.Evidence Document 2.Unit 9: – Communication ( ) 3.Unit 10: - Document Production (Word) 4.Unit 16: PowerPoint 5.Unit.
CIS 338: VB Variables Dr. Ralph D. Westfall April, 2011.
B065: PROGRAMMING Variables 2. Starter  What is wrong with the following piece of code: Option Explicit Off Dim num1 as string Dim num2 as integer num1.
More Visual Basic Code: if-then-else, for loops Controls: Multiple forms, List Boxes, Radio buttons, frames,
Learning Javascript From Mr Saem
Making Interactive Programs with Visual Basic .NET
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Unit 2 Technology Systems
Component 1.6.
A variable is a name for a value stored in memory.
UNIT 5 Lesson 15 Looping.
Component 1.6.
Variables ICS2O.
CHAPTER FOUR VARIABLES AND CONSTANTS
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Intro to Programming Concepts
B065: PROGRAMMING Variables 1.
B065: PROGRAMMING Variables 2.
Variables and Constants
Presentation transcript:

CW-V1 SDD 0601 Principals of Software Design and Development Variables Constants Data Types Error Handling Starter: BlockbustersBlockbusters

CW-V1 SDD 0602 Learning Objectives Describe Variables and Constants Further describe the Error handling Identify the need for good documentation of the above Improve the Business Card Program!

CW-V1 SDD 0603 Variables A variable is a named piece of memory that holds information Think of it like a glass that can hold a measured amount of something The contents of the glass is called a data type The amount of contents would be its value

CW-V1 SDD 0604 Declaring Variables We declare variables to tell the program:  Their Name  What they will hold Dim Glass as Beer Glass = “Full” Declaration Keyword NameData type Initialise the variable Initial value: Full

CW-V1 SDD 0605 Declaring and Initialising Variables Dim PupilName as String Dim PupilGrade as Integer Name = “Hermione” Grade = 10 Variable names cannot contain spaces. Begin each word with a capital instead

CW-V1 SDD 0606 Variables Its value can be changed within the code Variables can be used to do mathematics It is better to use a variable than just type in a number  Makes code easier to read  Changes can be made more easily

CW-V1 SDD 0607 Data Types A variable can only be of one data type Some data types take up more memory than others Always use the least amount of memory possible to keep programs running efficiently Some data types have specialist functions

CW-V1 SDD 0608 The Money Trap The Currency data type cannot be formatted to display only two decimal places – this is a problem with VB6 To display money properly you must use Single Single variables may be formatted to display a set number of decimal places  Dim Cost as Single  Cost = 5.99 The pound sign will be added later when the value is displayed.

CW-V1 SDD 0609 Quiz Declare and Initialise variables for the following scenarios  A telephone number –  The name of a course – A Level English  A student’s age – 17  Student’s date of birth – 01/02/1989  A bus fare - £3.50  Dinner tickets issued – Yes  Student Name – Tom Brown

CW-V1 SDD Quiz Dim TelNo as String Dim Course as String Dim Age as Integer Dim DateOfBirth as Date Dim BusFare as Single Dim DinnerTickets as Boolean Dim StudentName as String

CW-V1 SDD Quiz TelNo = “ ” Course = “A Level English” Age = “Integer” DateOfBirth = “01/02/1989” BusFare = 3.50 DinnerTickets = True Student Name = “Tom Brown”

CW-V1 SDD Constants Constants are like variables that cannot be changed once initialised Use them for values that will not change while the program is running, e.g. VAT Make things easier to remember e.g. the colour constant vbGreen replaces the value &H0080FF80& !! Their names usually begin with “c” e.g. cMin

CW-V1 SDD Calculations Use variables just like numbers! Dim FirstNo as Integer Dim SecondNo as Integer Dim Result as Integer FirstNo = 2 SecondNo = 5 FirstNo + SecondNo = 7 SecondNo – FirstNo = 3

CW-V1 SDD Comparisons Operators are used to compare two values x = yx is exactly the same as y OR make x the same as y x > yx is bigger than y x < yx is smaller than y x >= yx is bigger than or equal to y x <= yx is smaller than or equal to y x <> yx is not the same as y

CW-V1 SDD Quick Quiz Use comparison operators to write expressions for these scenarios  Phone bill is higher than gas bill  Pink is not equal to green  Electric bill is the same or less than gas bill  Starburst same as Opal Fruits

CW-V1 SDD Quick Quiz PhoneBill > GasBill Pink <> Green ElectricBill <= GasBill Starburst = OpalFruits

CW-V1 SDD Option Explicit Your New Best Friend Who has had problems with spelling mistakes in code? Put Option Explicit in the General Declarations of a form’s code  Keywords, variable and constant names are capitalised and corrected  Errors are highlighted when you run code

CW-V1 SDD Error Handling – Why Bother? Errors can make programs  Crash, freeze or end unexpectedly  Difficult to use  Give inaccurate information Try to think of errors likely to occur Test for errors Trap errors – tell the computer what to do if they occur, e.g. display a message It is never possible to trap all errors!

CW-V1 SDD Error Messages Good error messages should  Explain what the problem was Use Plain English Give examples if necessary  Why it occurred  How to fix it  What the user should do next  Give options as appropriate

CW-V1 SDD More about MsgBox Title Style (icon) Style (buttons) Message Put line breaks into your messages by using the constant vbctrlf e.g. MsgBox “This will be the top line” & vbcrlf & “and this will be the bottom line” Default choice Message boxes can be customised to be more user friendly