Presentation is loading. Please wait.

Presentation is loading. Please wait.

Developing Software Applications Introduction to Programming Fundamentals Scoping in VB Simple Ifs in VB.

Similar presentations


Presentation on theme: "Developing Software Applications Introduction to Programming Fundamentals Scoping in VB Simple Ifs in VB."— Presentation transcript:

1

2 Developing Software Applications Introduction to Programming Fundamentals Scoping in VB Simple Ifs in VB

3 VB Applications An application is simply a program A program is a collection of instructions (statements) that tell the computer what to do. A program is called software Hence, program, software and instructions are synonymous. A program is written in a programming language and is converted into the computer's machine code.

4 Program Introduction All programs have basic requirements They must allow users to interface with system. - INPUT / OUTPUT They must cater for the temporary storage of data in memory whilst the program is running – DATA STRUCTURES They must use the principles of computer logic to process the underlying data – CONTROL STRUCTURES

5 Designing applications methodically Don’t just start a program immediately, you must do thorough planning before ANY programming is written Take a structured approach Try and adhere to a software development life- cycle

6 In Visual Basic … VB allows the programmer to design I/O from the potential users perspective VB uses a Graphic User Interface (GUI) Logical processes are distributed to events which can be identified concurrently

7 Understanding the problem You must first develop a full understanding of the problem This is difficult to do: - Users do not know what they want! - Often ‘speak a different language’ - Change their minds!

8 Specifying the problem When problem is understood, then a program specification can be produced to embody what is required The problem may require several operations which need to be separate functions of the system Each operation may require a separate view (in VB, a new Form)

9 Pat sName Short review from last week ….

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

11 More on data types – numerical which one to use ? Integer Long Single Double Currency

12 String Text Fixed or variable length Fixed - from 0 to 65,500 characters in length Variable – up to 2 billion characters If the average length of a word is 7 characters this equates to …..

13 Boolean data type Boolean True or false represented by some systems as 1 or 0 Can be used as a “Yes or No” option check box - “the task has been done” Useful function but may not transfer to other languages

14 Scoping How does how (& where) I declare a variable e.g Diminside an event Private at the top of a form Public in a module affect the scope of where that variable may be used ?

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

16 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

17 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

18 Declaring Global variables Select Project | Add Module Code examples : Public sTeamName As String Public iNoOfMembers As Integer Public Const BasicHandicap = 21

19 Projects with more than 1 form Etc ~

20 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

21 Dealing with choices : simple IF statements In English: If exam mark greater than 40 Then set grade to Pass Coding: If iMark > 40 Then sGrade = “Pass” End If

22 If …… Then ….. Else ….. If …………………. Then …………. Else …………. End If

23 Example : If iMark > 40 Then sGrade = “Pass” Else sGrade = “Fail” End If

24 Nested IFs If iMark > 60 Then sGrade = “Merit” Else If iMark > 40 Then sGrade = “Pass” Else sGrade = “Fail” End If

25 Planning this out in Structured English / Pseudocode Input exam mark IF exam mark > 60 THEN set grade to Merit ELSE IF exam mark > 60 THEN set grade to Pass ELSE set grade to Fail END IF Output grade


Download ppt "Developing Software Applications Introduction to Programming Fundamentals Scoping in VB Simple Ifs in VB."

Similar presentations


Ads by Google