Basic Computer Programming Using VB6
Basic Computer Programming Using VB6
Malimata
At the end of this lesson, you should be able to: 1. Define program and programming 2. Give the meaning of algorithm, pseudocode and flowchart. 3. Enumerate the advantages of making an algorithm, pseudocode and flowchart. 4. Design algorithms and pseudocodes. 5. Name the flowcharting symbols.
7. 8.
9.
Draw the flowcharts. Follow the guidelines in creating a flowchart. Develop critical, logical and analytical thinking in preparing for program writing.
Programming
Logic formulations and problem-solving are the fundamentals of programming. It requires an intricate process of critical and analytical thinking combined with precision and keenness to details. The planning stage is very important because it serves as the backbone of any program.
logical procedure or set of steps to be followed to arrive at a solution to a problem. An algorithm is the breaking down of a problem into simple steps in order to find the right answer.
Recipe in a cookbook a complicated dish is broken down into simple cooking instructions.
Choreography of a dance a difficult dance is broken down into a succession of basic steps Word problem in Math a complex problem in Math is broken down into parts to arrive at a solution.
An
algorithm in English statements in an outline form. This is used to conceptualize the flow of the program before encoding it in a programming language.
The graphical representation of an algorithm. Flowchart is the pictorial description of sequenced activities and logic to be performed by the computer for carrying out data processing. It uses special symbols which represent a specific function.
Flowcharts are used by programmers before the actual start of any programming activity. Flowchart is otherwise known as Data Flow Diagram Flowcharts are used by programmers before the actual start of any programming activity. Flowchart is otherwise known as Data Flow Diagram Flowchart is the so called BLUE PRINT of a program.
TERMINAL - Represents the beginning and the end of the program. It contains the words Begin or Start and End or Stop.
PROCESS OR ACTION -Represents a step or an instruction such as comparison or arithmetic operations. Ex: Gather all materials in a box; Add 5 and 7 INPUT OR OUTPUT - Represents the step wherein information such as letters and numbers are entered byt he user or produced by the process. Ex: Input 3 numbers; Get A, B, C;
Print A
ARROW OR FLOW DIRECTION INDICATOR Indicates the flow of direction or the next activity.
DECISION Denotes a decision to be made. It involves 2 courses of action that is answered by either yes/true or no/false wherein one has to chosen. The symbol represents the if..then{, and the for .. Next statements PREPARATION Represents the process that will change the direction of initialization of any value or the execution of a variable.
PREDEFINED PROCESS OR SUBROUTINE Indicates a submodule or subflowchart embedded within a larger process. It can be described in a detail in a separate flowchart.
ON-PAGE CONNECTORS Indicates that the process is continued where the matching on page connector is placed (either on the same page or at a different page)
BEGIN
Take vitamins
END
BEGIN
No END
1.
2. 3. 4.
understood. It determines the validity of the processes involved in the program. Debugging or correcting of errors becomes less complicated. It produces effective program documentation.
1.
1.
2. 3.
There should be only be one start/begin and stop/end processes. Concentrate on the logic of the program. Choose only the important steps. No need to represent all the steps in the flowchart.
2 classifications of programming language. These pertains to the ways on how the program are written. High level programming resembles human language and corresponds to several machine language instructions Low level programming or machine language, describes exactly the procedures to be carried out by the computers central processing unit
1.
2.
3. 4.
5.
6. 7.
Okay now, start getting busy by doing your first exercise for this module.
Plant and produce carrots Charter change (with decision box) Get the area of a rectangle Input 2 numbers and print the larger number Get the quotient of 2 numbers and print the quotient if it is greater than 5 Compute and print for the average of 3 numbers
A program handles different data to be processed by the computer. These data are classified into different types: Numeric data
Integer - whole Float or Double numbers with decimal
Alphanumeric Data
Number numbers that cannot be used for mathematical operations
allocates a portion of the memory depending on the type of data a variables holds.
It must begin with a letter or an alphabet and may be followed by combinations of alphanumeric characters. The name of the variables should be indicative of the value it holds. Avoid using confusing letters or numbers such as zero and the letter O. Use underscore in replacement of a space.
Lessen the number of characters of your variable. The shorter the variable, the better and more efficient the program will be In most cases, uppercase and lowercase letters are read differently A and a may hold different data
Constants are values that do not change during the execution of the program.
Examples:
Pi = 3.1416 X=100
Classifications of Operators
Arithmetic Operators
Addition Subtraction Multiplication
Logical Operators
AND OR NOT
Input 2 whole numbers. Compute and print the sum of the 2 numbers
When a problem involves the 3 Types of operators, the following order should be followed. Evaluation of different types of operators
The hierarchy is as follows:
1st Arithmetic operators 2nd Comparison operators
3rd logical operators
Input 5 numbers. Find the sum, difference and product of the number. Print the answer Convert a number in degree Fahrenheit (0F) to Celsius (C)
A rectangular table has a length of 60.5 inches and a width of 20.5 inches. Find and print the perimeter.
Conditional statements is one of the vital components in programming. It enables a program to respond in a different manner every time a program is executed depending on the data entered. The commonly used conditional statements are:
If statement If ...then.. Else statements Select case statements
This is used to evaluate a condition or check a value as true or false. If the condition is not met, the succeeding statements or set of statements will executed. Syntax If condition Statement End if
Input a color. If the color is blue, display the message The color is blue. Algorithm:
String color Begin Input color If color= blue Print The color is blue End If End
This is used to evaluate a condition or check a value as true or false. If the condition is not met, the statement or set of statements after will be executed Syntax:
If condition then Statement 1 Else Statement 2 End if
If condition then Statement(s) Else if condition 1 then Statement(s) Else if condition 2 then Statement(s) Else Statement(s)
Input a grade. If the grade is greater than or equal to 75, display the message You passed the subject, otherwise display Study hard Input 2 prices and get the total. If the total is more than P500, get 5% of the total, if the total is more than P500 but less than or equal to P1000, get 10% of the total, but if the total is greater than P1000, get 15% of the total. Display the discounted price.
The case statement is similar to the use of the If... Then .. Else statement. It is used when a variable is compared to different values or expressions. Syntax Select Case test expression Case expressionlist1 Statement Block1 Case expressionlist2 Statement Block2 End Select
Conduct Grade Equivalent 1 Excellent 2 Very Good 3 Good 4 Satisfactory 5 Needs Improvement Input a conduct grade and display the equivalent rating
Okay now, start getting busy by doing your first exercise for this module.