Visual Basic Programming

Slides:



Advertisements
Similar presentations
CS 101 Introductory Programming - Lecture 7: Loops In C & Good Coding Practices Presenter: Ankur Chattopadhyay.
Advertisements

CS 240 Computer Programming 1
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
CS 240 Computer Programming 1
CS0004: Introduction to Programming Repetition – Do Loops.
 Control structures  Algorithm & flowchart  If statements  While statements.
ITEC113 Algorithms and Programming Techniques
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
Program Design and Development
Loops – While, Do, For Repetition Statements Introduction to Arrays
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Chapter 1 Program Design
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.
The Program Design Phases
Variables, Constants, Methods, and Calculations Chapter 3 - Review.
CIS Computer Programming Logic
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Chapter 12: How Long Can This Go On?
Lecture 4 Introduction to Programming. if ( grade ==‘A’ ) cout
Programming Logic and Design Fifth Edition, Comprehensive
Mr. Dave Clausen1 La Cañada High School Chapter 6: Repetition Statements.
Fundamentals of GUI Programming. Objectives: At the end of the session, you should be able to: describe the guidelines that are used for creating user-friendly.
Programming Logic and Design Sixth Edition Chapter 5 Looping.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
ITEC113 Algorithms and Programming Techniques
Lab 4 Range Review, Control Logic and Loops ► Range Review ► Control Logic and Loops ► Exercise.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 4 Looping.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Class Average Application Introducing the Do...Loop While and Do...Loop Until.
Algorithm Design.
A loop is a repetition control structure. body - statements to be repeated control statement - decides whether another repetition needs to be made leading.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
Introduction to Problem Solving and Control Statements.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 10 - JavaScript/JScript: Control Structures II Outline 10.1Introduction 10.2Essentials of.
Control Structures RepetitionorIterationorLooping Part I.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Looping.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 13 How Long Can This Go On?
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Chapter Looping 5. The Increment and Decrement Operators 5.1.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
Chapter Looping 5. The Increment and Decrement Operators 5.1.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Computer Programming 12 Lesson 6 – Loop structure By: Dan Lunney.
Sesi 0607EKT120/4 Computer Programming Week 5 – Repetition / Loops.
26/06/ Iteration Loops For … To … Next. 226/06/2016 Learning Objectives Define a program loop. State when a loop will end. State when the For.
REPETITION CONTROL STRUCTURE
GC211Data Structure Lecture2 Sara Alhajjam.
Loop Structures.
The Selection Structure
Lecture 4 - Loops UniMAP EKT120 Sem 1 08/09.
Lecture 2 Introduction to Programming
Introduction To Flowcharting
Chapter 4 – Control Structures Part 1
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Unit# 9: Computer Program Development
MSIS 655 Advanced Business Applications Programming
Structured Program
3 Control Statements:.
` Structured Programming & Flowchart
Chapter 6: Repetition Statements
Fundamentals of visual basic
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Presentation transcript:

Visual Basic Programming FLOWCHART Construction CODING

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.

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

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

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%

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

Create the User Interface

Set the Properties of the Objects

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

Enter the Source Code

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

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

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

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$

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

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!”

Run the Program

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.

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

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

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

RELATIONAL OPERATORS > >= = <= < <>

LOGICAL OPERATORS NOT AND XOR OR

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

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 – 89 B 70 – 79 C 69 and below D

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

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).

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.

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

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

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

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

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

+ = 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 = +

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

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