1 / 38

Visual Basic Programming

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.

criderl
Télécharger la présentation

Visual Basic Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Visual Basic Programming FLOWCHART Construction CODING

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

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

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

  5. 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% SEQUENCE

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

  7. Create the User Interface

  8. Set the Properties of the Objects

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

  10. Enter the Source Code

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

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

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

  14. 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$

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

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

  17. Run the Program

  18. 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. SEQUENCE

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

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

  21. 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 BOOLEAN Expression

  22. RELATIONAL OPERATORS > >= = <= <> <

  23. LOGICAL OPERATORS NOT AND XOR OR

  24. 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 SELECTION

  25. 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 EXERCISE 1 (Seatwork Size 2 CW)

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

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

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

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

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

  31. 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 WHILE / DO UNTIL

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

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

  34. COUNTER **Counter 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 CT 1 New Value Current Value Increment Value

  35. Accumulator 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

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

More Related