Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class 3 Remote Instruction Decision Structures and Global Variables EDU 556 Programming for Instruction Dr. Steve Broskoske This is an audio PowerCast.

Similar presentations


Presentation on theme: "Class 3 Remote Instruction Decision Structures and Global Variables EDU 556 Programming for Instruction Dr. Steve Broskoske This is an audio PowerCast."— Presentation transcript:

1

2 Class 3 Remote Instruction Decision Structures and Global Variables EDU 556 Programming for Instruction Dr. Steve Broskoske This is an audio PowerCast. Make sure your volume is turned up, and press F5 to begin. Click to advance as usual.

3 Global Variables Remember there are 3 places you can declare a variable, depending on how long you want the variable to “live.” – Whole program (global—declare in a module). – Form (declare on top of form). – Button (declare within button procedure/coding).

4 To Declare a Global Variable Select add new item—module. – The module will appear in the Solution Explorer. – Only code on module; no design. Declare the global variable in the module using the following coding: Friend variable_name As type

5 Global Variable Example 56 globalCounter = globalCounter + 1 lblOutput.Text = globalCounter

6 Decision Structures If condition Then statement Example: If score >= 70 Then lblOutput.text = “pass” End If

7 Decision Structures If condition Then statement Else statement Example: If score >= 70 Then lblOutput.text = “pass” Else lblOutput.text = “fail” End If

8 Conditional Statements Conditions = (equal to) <> (not equal to) > (greater than) < (less than) >= (greater than or equal to) <= (less than or equal to) Examples If score = 12 Then… If answer <> 10 Then… If age > 21 Then… If numCorrect < 3 Then… If score >= 70 Then… If answer <= 35 Then… If condition Then statement Else statement

9 Test Questions: Textboxes Test question. If txtInput.Text = “George Washington" Then totalCorrect = totalCorrect + 1 End If Use the If statement to see if the text property holds the correct answer.

10 Test Questions: Radio Buttons Test question. If RadioButton1.Checked = True Then totalCorrect = totalCorrect + 1 End If RadioButton1 RadioButton2 Radiobutton3 With radio buttons, the user can only select 1 answer. Use the If statement to see if the checked property for the correct answer is true.

11 Test Questions: Check Boxes Test question. If CheckBox1.Checked = True Then totalCorrect = totalCorrect + 1 End If Checkbox1 Checkbox2 Checkbox3 With check boxes, the user can select as many answers as desired. Use the If statement to see if the checked property for the correct answer is true.

12 Test Questions: Textboxes 3 lblOutput.text = totalCorrect Because we declared a global variable in the module, we can show the total correct on this form. Coding for “end” button is: End

13 Review Declare a global variable: – Friend variable_name As type – Declare in module. Conditional statements: – If condition Then statement – If condition Then statement Else statement Use a global variable with text boxes, check boxes, and radio buttons to create test questions and score them.


Download ppt "Class 3 Remote Instruction Decision Structures and Global Variables EDU 556 Programming for Instruction Dr. Steve Broskoske This is an audio PowerCast."

Similar presentations


Ads by Google