Presentation is loading. Please wait.

Presentation is loading. Please wait.

Course ILT Using complex selection structures Unit objectives Include radio buttons and check boxes in an interface, create and call a user- defined Sub.

Similar presentations


Presentation on theme: "Course ILT Using complex selection structures Unit objectives Include radio buttons and check boxes in an interface, create and call a user- defined Sub."— Presentation transcript:

1 Course ILT Using complex selection structures Unit objectives Include radio buttons and check boxes in an interface, create and call a user- defined Sub procedure, use the Random object, and process code when a form is loaded into the computer’s memory Select the existing text in a text box control, code a check box control’s Click event procedure, and display and hide a control

2 Course ILT Topic A Topic A: The Math Practice application Topic B: Completing the Math Practice application

3 Course ILT Completing the user interface The application should display the addition or subtraction problem on the screen, then allow the student to enter the answer and then verify that the answer is correct If the student’s answer is not correct, the application should give him or her as many chances as necessary to answer the problem correctly

4 Course ILT Adding a Radio button RadioButton control is used to limit the user to only one choice in a group of options RadioButton control should have a unique access key, which allows the user to select the button using the keyboard

5 Course ILT Default Radio buttons The selected button is called the default radio button and is either the radio button that represents the user’s most likely choice or the first radio button in the group You designate a radio button as the default radio button by setting the button’s Checked property to the Boolean value True

6 Course ILT Activity A-1 Adding a radio button

7 Course ILT Adding a Check box Checkbox controls are used to add a check box control to the interface Checkbox controls work like radio buttons in that they are only either selected or deselected continued

8 Course ILT Adding a Check box, continued You use Checkbox controls to permit the user to select any number of choices from a group of one or more independent and nonexclusive choices Any number of check boxes on a form can be selected at the same time

9 Course ILT Activity A-2 Adding a check box

10 Course ILT Activity A-3 Using the radio buttons and check boxes

11 Course ILT User-Defined procedures A user-defined Sub procedure is a collection of code that can be invoked from one or more places in an application Enter Private Sub SubName() just above the End Class statement The rules for naming a user-defined Sub procedure are the same as those for naming variables and constants The End Sub will automatically be generated

12 Course ILT Activity A-4 Creating a user-defined Sub procedure

13 Course ILT Generating Random numbers Visual Studio.NET provides a pseudo- random number generator, which is a device that produces a sequence of numbers that meet certain statistical requirements for randomness Dim GeneratorRandom As New Random() Methods –Next(minValue, maxValue) –NextDouble()

14 Course ILT Generating Random numbers, examples

15 Course ILT Activity A-5 Generating random numbers

16 Course ILT RadioButton Click event You can use the Visual Basic.NET Call statement, whose syntax is Call procedurename ([argumentlist]), to call (invoke) a user-defined Sub procedure The square brackets in the syntax indicate that the argumentlist is optional

17 Course ILT RadioButton Click event, examples

18 Course ILT Activity A-6 Coding the Grade1RadioButton and Grade2RadioButton Click events

19 Course ILT Addition and Subtraction events When the user clicks either the AdditionRadioButton control or the SubtractionRadioButton control, the control’s Click event procedure should display the appropriate mathematical operator and then generate and display two random numbers in the Num1Label and Num2Label controls

20 Course ILT Addition & Subtraction events, examples

21 Course ILT Activity A-7 Coding the AdditionRadioButton and SubtractionRadioButton events

22 Course ILT The Load event procedure Instructions entered in the form’s Load event procedure are processed when the application is started and the form is loaded into memory The following statement uses the RandomButton.PerformClick method, whose syntax is radiobutton.PerformClick(), to call the Addition radio button’s Click event, continued

23 Course ILT The Load event procedure,continued

24 Course ILT Activity A-8 Coding the Load event for a form

25 Course ILT Topic B Topic A: The Math Practice application Topic B: Completing the Math Practice application

26 Course ILT Activity B-1 Coding the CheckAnswerButton Click event

27 Course ILT SummaryCheckBox Click event The SummaryCheckBox control’s Click event procedure is responsible for both displaying and hiding the SummaryGroupBox control The procedure should display the group box control when the user selects the check box, and it should hide the group box control when the user deselects the check box

28 Course ILT SummaryCheckBox event, completed

29 Course ILT Activity B-2 Coding the SummaryCheckBox Click event

30 Course ILT Unit summary Learned how to Include radio buttons and check boxes in an interface, create and call a user-defined Sub procedure, use the Random object, and process code when a form is loaded into the computer’s memory Select the existing text in a text box control, code a check box control’s Click event procedure, and display and hide a control


Download ppt "Course ILT Using complex selection structures Unit objectives Include radio buttons and check boxes in an interface, create and call a user- defined Sub."

Similar presentations


Ads by Google