Top
Week 4
System
Select Statements
A selection statemetn is a type of conditional statement, these allow the the programmers to make a choice/selection about
which lines of code to run. Within VB .NET® a number of selection types are available the commonly used are
‘If…then…else’ and ‘Select…Case’.
The ‘If...then…else’ statement
Understanding the above code, the first TextBox (TextBox1) will allow the entry of a date in the format dd/mm/yy, e.g.
29/08/81 would be entered for 29 August 2081.
The second TextBox (TextBox2) will allow entry of a time.
If a user were to enter an invalid date (tested using the IsDate function in VB .NET®),
the first part of the ‘If…then….else’ statement displays a message box and then user is returned to the Date TextBox (TextBox1)
for another try.
There is a test for a valid date when the user moves away from the Date TextBox. This is performed by the ‘Leave’ event handler.
But if the user enters a valid date, the ‘else’ part of the ‘If…then…else’ function is ran. This simply pops up a message box,
but displays a confirmation that the date was acceptable.

Select…Case statement
Case statements are usualy found in places where code is simplified to enable a program to match a single value (or range of values)
from a list of given possibilities.
Example of the ‘Select…Case’ statement.

Loops
Loops allow a program to perform a number of actions repeatedly. Unless the loop is infinite, it will have an element or condition statement
that will make it to stop.
Within the VB .NET framework there are a number of different loops that can be used these are,
For…Next
The ‘For…Next’ statement is one of the most commonly used tools in almost all programming languages. A loop uses a predefined
number of times that is set by a programmer, that a piece of code is ran until a statement is met, usually controlled by a counter.
The example below shows how an application uses a ‘For…Next’ loop to generate a child’s times table based on two inputs (the table number
itself and the number of rows required).
Do…loop
The ‘Do…’ loop can either check a condition before- or after the lines of code that are being repeated. The example below a vowel counter uses the Do…’ loop. The event handler is triggered when a new keystroke is made. The application then runs a check after the condition ‘Do…’ loop which repeats until the counter is greater than the length of the current text stored in TextBox1. Inside the loop, a ‘Select…Case’ is used to examine each character (by using the MIDfunction) and increment the appropriate counter when a vowel is matched.
While…End
This works in a similar fashion to the pre-check ‘Do...’ loop as shown above, so we won’t dwell too much on it here!
Using the tutorial sheet above create the code to enable the use of one of the above covered loops
5 min's
How an operating system can be viewed as an event driven application
Event driven programs for non-graphical applications
Where might this happen? Well if we look closer you may find them in a number of places that you might never of considered, things like;
- Alarms
- Traffic light systemes
- Microwaves
- Washing Machines
- DOS (Disk Operating System) aka Command line (CLI)
- TV remote
Other places are discussed in the short video below.
1. Name three different event driven programming languages.
2. Common triggers can be caused by the ______or the ________? Complete this sentence.
3. Name three possible system events.
4. Give three advantages of event driven programming languages.
5. Give three disadvantages of event driven programming languages.
EXTENTION
EXTENTION
STRETCH & CHALLENGE
The information covered in this page covers the knowledge and understanding linked to the criterion in the table below.
| Links to Assessment Criteria | Description |
|---|---|
| LO1 |
Understand the features of event driven programming: Key features: service oriented; time driven; event handlers; trigger functions; events eg mouse, keyboard, HTML object, form, user interface; event loops; flexibility; suitability for graphical interfaces; simplicity of programming; ease of development |
| LO2 |
Be able to use the tools and techniques of an event driven language: Triggers: eg key press, alarm, system event, touch screen event, mouse click Tools and techniques: eg use of tool boxes and controls, selection, loops, event handlers, triggers, objects and object properties, menus; debugging tools Variables: declaring variables; scope of variables; constants; data types |
| Functional Skills English | Reading, Writing, Comprhension, Problems Solving, Nouns |
| Functional Skills Maths | Compression,Reduction |
| British Values | None covered in this session. |
| Equality and Diversity |
Last Updated
2018-04-16 13:27:00
English and Maths
English
0Maths
Stretch and Challenge
Stretch and Challenge
Homework
Homework
Equality and Diversity Calendar
How to's
How to's Coverage
00
Links to Learning Outcomes |
Links to Assessment Criteria |
|
|---|---|---|
Files that support this week
→
Next ←
Prev