Presentation is loading. Please wait.

Presentation is loading. Please wait.

Developing Software Applications Introduction to Variables & Data Types in VB State Transition Diagrams.

Similar presentations


Presentation on theme: "Developing Software Applications Introduction to Variables & Data Types in VB State Transition Diagrams."— Presentation transcript:

1 Developing Software Applications Introduction to Variables & Data Types in VB State Transition Diagrams

2 Variables - Introduction A computer stores data in its memory. To store data, your program must tell the computer to set aside a block of memory. To do this you use variables. A variable is often compared to a box in which a value is stored. 10 iNum Value Name

3 Pat sName

4 Declaring variables Each variable has to be ‘declared’ before it is used E.g: Dim iCount As Integer This sets up a memory area 0 iCount

5 Naming conventions iTotalIntegere.g 387 fAverageFloating Pointe.g 12.34 cSalaryCurrencye.g £4.28 sNameStringe.g Pat

6 Rules for variable names  must start with an alphabetic character  may only contain alphanumeric characters and the underscore _  may not exceed 240 characters  must not be a VB keyword

7 What code might need to use the data? Just in one event Just in one form In several forms

8 Dim, Private or Public ? Just in one event use Dim at start of that event this is called local data In more than one event but just in one form use Private after Option Explicit at top of code for that form this is called form level data

9 In more than one form Use Public Code in a Module This is called Global or Code level data Summarising : In 1 eventDim In 1 FormPrivate In several formsPublic

10 Examples Variables ~ Dim iCount as Integer Private dAverage as Double Public sName as String Constants ~ Const dVatRate = 17.5 n.b. no type declaration needed with constants

11 Data Types ~ summary

12 Arithmetic Operators Addition, subtraction+ - Multiplication, division * / Integer division \ Modulo arithmeticMod Exponentiation^ String concatenation &

13 Arithmetic Operators Order of precedence – Brackets Operands Division Multiplication Addition Subtraction

14 Projects with more than 1 form Etc ~

15 A State Transition Diagram ~ helps us to plan how the project will flow between different forms (or ‘states’) Add / Subtract form Mult / Square form Enter Name form Menu form Continue Start Exit Add or Subtract Return to Menu Mult or Square Return to Menu


Download ppt "Developing Software Applications Introduction to Variables & Data Types in VB State Transition Diagrams."

Similar presentations


Ads by Google