Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
This chapter is from the book

3.17 Summary

The If/Then single-selection structure selects or ignores a single action (or a single group of actions), based on the truth or falsity of a condition. The If/ThenElse / double-selection structure selects between two different actions (or groups of actions), based on the truth or falsity of a condition.

The While and Do While/Loop repetition structures allow the programmer to specify that an action is to be repeated while a specific condition remains true. Eventually, the condition in a While, DoWhile/Loop or Do/LoopWhile structure becomes false. At this point, the repetition terminates, and the first statement after the repetition structure executes.

The Do Until/Loop and Do/Loop Until repetition structures allow the programmer to specify that an action is to be repeated while a specific condition remains false. Eventually, the condition in a Do Until/Loop or Do/Loop Until structure becomes true. At this point, the repetition terminates, and the first statement after the repetition structure executes. The For/Next repetition structure handles the details of counter-controlled repetition. The required To keyword specifies the initial value and the final value of the control variable. The optional Step keyword specifies the increment. The Exit Do, Exit While and Exit For statements alter the flow of control by causing immediate exit from a repetition structure.

Visual Basic provides the SelectCasemultiple-selection structure so that a variable or expression may be tested separately for each value that the variable or expression might assume. The Select Case structure consists of a series of Case labels and an optional CaseElse.

The logical operators are AndAlso (logical AND with short-circuit evaluation), And (logical AND without short-circuit evaluation), OrElse (logical inclusive OR with short-circuit evaluation), Or (logical inclusive OR without short-circuit evaluation), Xor (logical exclusive OR) and Not (logical NOT, also called logical negation).

With visual programming, the IDE actually generates program code that creates the GUI. This code contains instructions for creating the form and every control on it. Windows application code is contained in a class. Like modules, classes are logical groupings of procedures and data that simplify program organization.

Forms and controls contain a set of default properties, which are displayed initially in the Properties window when a form or control is selected. These default properties provide the initial characteristics that a form or control has when it is created. When a change is made in design mode, such as when a property value is changed, the Windows Form Designer creates code that implements the change. Often, it is necessary to modify a property while a program is running. In Windows applications, the code that implements the change is placed in a procedure that executes when the form is loaded, which can be created by double-clicking the form in design view.

  • + Share This
  • 🔖 Save To Your Account