Tip:
Highlight text to annotate it
X
In this lesson, we will discuss flowcharts.
As your programs become more complicated, often it is helpful to visualize the data flow throughout the program using flow charts.
The beginning and end of a program are represented by rectangles with rounded corners.
The flow of logic in a program is represented by arrows.
Calculations and data manipulation are represented by rectangles with sharp corners
A point where a program where input is required or where the program produces output is represented by a rhombus.
A diamond represents a point where a comparison is made which determines the path of logic.
Circles represent where flow lines converge.
A block arrow represents a loop that repeats a specific number of times. In VBA, this symbol is used to represent For loops.
Let’s see how a flowchart can represent a program that contains an If-Then-ElseIf structure.
In this program, x and y are declared as Double variables and x is input by the user through an input box.
Next, an If-Then-ElseIf structure begins.
If x is less than or equal to 0, y will be assigned the value 11.
If this test condition is False, we will evaluate the second test condition.
If x is greater than 0 and x is less than or equal to 8, y will be assigned the value 22.
If that test condition is False as well, y will be assigned the value 33.
After the If structure is finished, the value of y will be displayed to the user through a message box.
Here is how the flow of logic can be represented in a flowchart.
After the program starts, x is input by the user.
We then come to our first decision.
Is x less than or equal to 0?
If this expression is True, we proceed down the True path on the right and y is assigned the value 11.
If the expression is False, we proceed down the False path to the left and arrive at another decision.
If x is greater than 0 and less than or equal to 8, we proceed down the True path to the right and y is assigned the value 22.
If the expression is False, we proceed down the left path and y is assigned the value 33.
Regardless of which path we take, we arrive at a junction.
The value of y is output and the program ends.