The purpose of the lesson: to give students an idea of how to write programs containing branching
Lesson objectives:
- to form the ability of students to compose programs of a branching structure in the VisualBasic language;
- development of cognitive interest in programming;
- to form the ability to listen to comrades when developing a common way to solve a problem.
Lesson type: combined lesson
Lesson plan
1. Organizing time
2. Testing students' knowledge of the topic passed
3. Learning new material
4. Lesson summary
5. Homework.
During the classes
1. Organizational moment.
Preparing the class for work: greeting, checking those present, familiarizing with the work plan in the lesson.
2. Testing the knowledge of students.
Stage 1. Frontal poll.
Survey students on key concepts from the Data in VB theme using the Data.ppt presentation
Stage 2. Individual work.
Students working on a computer with a flipchart Data in VB.flp. At the end of the work, the flipchart is saved in the student's folder, the solution is checked according to the sample, the errors are analyzed, and the preliminary assessment of the work.
3. Learning new material.
1. Preparation for the study of new material.
The task: Create a program in which the user enters a number into a text field, and the program displays the square of this number using the Text box.
Questions:
1. What elements will be located on the form? (Estimated answers: text box, caption)
2. What actions will the user perform in the program? (enter number)
3. What actions should the program take? (read the entered text, convert it to a number, square the number, display the result) - these actions are recorded on the board
4. What element is required for the program to perform actions? (button)
5. What will the button code look like?
Notes on the board:
Algorithm |
Program |
1. Read the entered text |
text1.text |
2. Convert text to number |
n = val (text1.text) |
3. Square the number |
m = n * n |
4. Display the result on the screen |
label1.caption = m |
The task: Run the project Number from your working folder. Consider the command button code. Change it so that the program calculates the square root of the entered number.
2. Learning new material.
Problem: How to change the program so that the computer “guesses” the number, and the person tries to guess this number?
Students offer their own options for solving the problem.
The main thing:
1. How can a computer "guess" a number? (random number from 1 to 100 - int (rnd * 101)
2. How will the computer determine if the entered number matches the intended one or not? (the operation sounds: if the entered number is equal to the intended one ..., otherwise ... What does it look like? How was a similar command written in Pascal? If ... then ... else ...)
3. Working with notes
The need to use the IfThenElse statement arises if there are alternative paths of program execution; when using it, conditions are checked and, depending on their truth, certain actions are performed. Simple and complete syntax is used.
Simple syntax:
If condition Then statement [Else statement]
- if the condition after If is true (True), then the statement following the Then is executed, if the condition is false (False), then the statement following Else is executed.
Complete syntax:
If condition 1 Then
instruction 1
...
[instruction m]
[ElseIf condition 2 Then
instruction k]
[Else
instruction n]
EndIf
In the second case of syntax, instruction 1 ... instruction m is written on new lines, there is an EndIf instruction. ElseIf allows you to parse additional conditions. By adding a few ElseIf statements, you can parse more conditions. Else is used to handle opposite situations. If you need to check a certain condition in the presence of another condition, then nested instructions are used, for example:
If condition 1 Then
If condition 2 Then
instruction 1
Else
instruction m
EndIf
Else
instruction n
EndIf
Our team can be written like this:
If m = n then
Out.caption = "Guess"
Elseif m> n then
Out.caption = "Little"
Else
Out.caption = "a lot"
End if
Physical education.
4. Independent work of students at the computer.
The task: Change the Number program so that the game is "Guess the Number"
4. Summing up the lesson
1. What new have you learned in today's lesson?
2. Grading students for a lesson.
5. Homework
Read the synopsis. General view of operators to teach.
Data in Visual Basic
(Verification work)
Surname _____________________________ Name _________________________
Data types |
Designation |
Brief entry (suffix) |
Whole |
|
|
Fractional |
|
|
String |
|
|
Arbitrary (numeric and string) |
|
|
* single, variant, long, real, integer, byte, string
**! & #% $
Variable scope:
Dim - __________________________________________________
Public - _________________________________________________
* local variable, global variable
By default, variables have:
Type - _________________________________________
Scope - ___________________________
* single, variant, long, real, integer, byte, string
** local variable, global variable
Declare a local variable of integer type:
______________________________________________________________________
Text to numeric conversion function: _______________
Numeric to text conversion function: _______________
* var, val, nun, vol, text, str, chislo
Correct answers: ______________ Score: _________
Материалы на данной страницы взяты из открытых источников либо размещены пользователем в соответствии с договором-офертой сайта. Вы можете сообщить о нарушении.