Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visual Basic Programming

Similar presentations


Presentation on theme: "Visual Basic Programming"— Presentation transcript:

1

2 Visual Basic Programming
FLOWCHART Construction CODING

3 OBJECTIVES: Define the three control structures clearly;
Construct program flowcharts and source codes that portray different control structures; and Appreciate the features of flowchart as a tool in program logic formulation.

4 CONTROL STRUCTURE controls the logical sequence in which computer program instructions are executed. Also known as Logic Structure 3 TYPES: SEQUENCE SELECTION ITERATION

5 What is Sequence Logic ? instructions are executed in order, from top to bottom. No decisions to make, no choices between “yes or no”

6 SEQUENCE Sample Problem 1:
Make a program that will solve for the grade of a student in Computer III using the following: Quizzes 20% CS 15% Lab 30% PT 35%

7 Steps in Creating Simple VB Applications
Create the User Interface (GUI) Set the Properties of the Objects Enter the appropriate Source Code Run the Program

8 Create the User Interface

9 Set the Properties of the Objects

10 Elements of a GUI Control
Property characteristics or parameters of a control Event an action or occurrence to which a program responds Method function of the control

11 Enter the Source Code

12 Variables Variable – a named memory location capable of storing values based on its definition Numeric: used to store a value which is numeric in nature String: used for storing strings **Variable Conventions

13 Data Types Data Type – an element of a variable that verifies the kind of data it can store. - Boolean - Short - Integer (9) - Long (17) - Single - Double - String

14 Variable Declarations
SYNTAX: Dim <variablename> as <data type> OR: Dim <variablename><suffix> Suffixes: Integer ( % ) Double ( # ) Single ( ! ) Long ( & ) String ( $ )

15 Sample Variable Declarations
Ex 1. X and Y are of integer data type. Dim X as integer Dim Y% Ex 2. Name is of string data type. Dim Name$

16 The Assignment Statement (INPUT)
SYNTAX: Variable = ObjectName.PropertyName WHERE: ObjectName – name of the control PropertyName – property of the control Variable - variable / identifier Ex: Name = txtSN.Text

17 The Assignment Statement (OUTPUT)
SYNTAX: ObjectName.PropertyName = Value WHERE: ObjectName – name of the control PropertyName – property of the control Value - a constant or a variable Ex: lblDisplay.text = “Hello!”

18 Run the Program

19 SEQUENCE Sample Problem 2 and 3:
Construct a flowchart that will solve for the Area and Perimeter of a rectangle. A program that accepts 2 numbers, solve for the sum, difference, quotient and product of the entered numbers.

20

21 What is Selection Logic?
A structure that represents a choice. Enables the computer to make decisions based on a given set of choices

22 SELECTION LOGIC 2 TYPES: Single Compound Single Alternative
Double Alternatives Compound Multiple Alternatives

23 BOOLEAN Expression refers to an operation that is carried out on variables that can only have two possible values: TRUE and FALSE uses relational and / or logical operators

24 RELATIONAL OPERATORS > >= = <= < <>

25 LOGICAL OPERATORS NOT AND XOR OR

26 SELECTION Sample Problem 1:
Make a program that will solve for the grade of a student in Computer III using the following: Quizzes 20% CS 15% Lab 30% PT 35% Determine whether the grade is passing or failing

27 EXERCISE 1 (Seatwork Size 2 CW)
Write a program that will assist a teacher in calculating student’s grade at the end of the grading period. The program will accept a numerical grade as input, then it will display the character grade as output based on the given scale: 90 and above A 80 – B 70 – C 69 and below D

28 Guidelines in Constructing Flowcharts
1. Flowchart symbols represent various operations 2. A flowchart starts with BEGIN / START and is completed by END / STOP. 3. Flow lines interconnect symbols. 4. The arrowhead of a flow line indicates the direction to be followed. It is optional when the flow is from top to bottom or from left to right

29 Guidelines in Constructing Flowcharts
5. The sequence of symbols is important. It indicates the step-by-step logic to follow. The terminal, Input/Output, Process and connector symbols must have only one arrow branching out, but may have more than one arrow branching in. The decision symbol must have two exit points (True/Yes and False/No).

30 Guidelines in Constructing Flowcharts
8. Use connector symbols to reduce the number of flow lines. Avoid intersecting flow lines to make it more effective and easier to follow. There may be varied flowcharts to solve one problem. There is no ONE correct flowchart. It is always useful to test the validity of the flowchart by passing through it with a simple test data.

31 What is Iteration Logic?
involves loops or cycles there are two types: WHILE DO UNTIL Provides a means of repeating a part of instruction without rewriting the part again and again

32 Two Parts of Iteration Structure
Body of the Loop Set of instructions which are repeated Loop-Exit Condition Condition to be tested before each repetition

33 WHILE / DO UNTIL The loop-exit condition is placed at the beginning of the loop WHILE it is not yet the end-of-file, read and process student records The exit from the loop is done at the end of the loop DO read and process student records UNTIL it is already the end-of-file

34 Procedure (body of the loop)
WHILE Structure: Condition Procedure (body of the loop) Yes No

35 Procedure (Body of Loop)
DO UNTIL Structure: Procedure (Body of Loop) Condition No Yes

36 + = COUNTER **Counter Format: CT 1
Used to literally count the number of times a portion of the flowchart is traced. Format: CT = CT + 1 Where CT is any variable CT 1 New Value Current Increment = +

37 Accumulator Format: S = S + N
A numeric variable which collects the results of a repeated mathematical operation Used to keep a running total of an item. Format: S = S + N ** SUM = SUM + N ** TotalScore = TotalScore + Score

38 ITERATION Make a program that will compute for the total score of all students in III – 1 in Quiz #1. Print the result. Construct the flowchart


Download ppt "Visual Basic Programming"

Similar presentations


Ads by Google