Using Subroutines
Sub Routines
- Subroutines are small sections of code that make it easy to keep a program organised.
- A program can have millions of lines of code. Without breaking it into small sections it would be very hard to keep track of any mistakes that could occur in the code.
- Because programs can grow very large it is a good idea to add comments to allow a programmer to know the purpose of a piece of code. At the very least, get in the habit of automatically adding a comment as the first line of any subroutine that you create.
Grabbing Data from the Form! Go Full Screen to see in greater detail?
|
1. Inputting Data from the Form To Do:-
- Watch which shows you how to grab data from a TextBox on your form.
- Create the subroutine input_number for the Upto100 program and save all files as shown in the movie
Processing the Data! Go Full Screen to see in greater detail?
|
2. Processing Data from the Form To Do:-
- Watch which shows you how to use or process the data from the form in a calculation.
- Create the subroutine calculate_number for the Upto100 program and save all files as shown in the movie.
Displaying the Output from the processing! Go Full Screen to see in greater detail?
|
3. Outputting or Displaying Data in The Form To Do:-
- Watch which shows you how to display the results of the process or calculation.
- Create the subroutine display_results for the Upto100 program and save all files as shown in the movie.
What you have to do!
- Watch and create a Sub Routine called input_number which is used to grab data from the form.
- Watch and create a subroutine which processes the data from the form.
- Watch Movie 10 and create a final subroutine which display the results of the processing.
Mark off Exercise 6 in your progress grids.
What you should now be able to do!
-
Create subroutines in a program.
-
Grab data from TextBoxes on a Form and store the data in variables.
-
Process the data by using variables in a calculation.
- Display the results or the output from the process in a ListBox.