Hardware and software setup

Six programming lessons in Visual Basic. Assoc.

Educational institution: KSU "Gymnasium No. 6"

The Republic of Kazakhstan

City of Semey

East Kazakhstan region

Lesson topic: Visual Basic programming language. Microsoft software download Visual Basic 6.0. Acquaintance with the constituent elements of the programming environment. First project in Microsoft Visual Basic 6.0.

Educational tasks:

1. Acquaintance with the constituent elements of the programming environment.

2. Introduce the structure of the integrated environment

Development tasks:

    Develop students' ability for algorithmic thinking.

    To expand students' knowledge in the field of algorithmization.

Basic knowledge and skills:

Know: The composition of the integrated environment,

Be able to:

    run Microsoft program Visual Basic 6.0.

    Save, open applications.

    set object property values ​​using the project properties window

    Place objects on the form and run the finished project for execution.

Ensuring the lesson:

one). PC - computer - 12 pcs.

2). Handout "My first program".

Literature:

    N.G. Volchenkov "Programming in Visual Basic 6.0"

    S.N. Lukin "Tutorial for working on Visual Basic 6.0"

Methods: verbal, practical, design.

Forms of work: lecture, practical work, frontal survey.

During the classes

    Organizational moment (3 min.)

Communication to students of the topic, tasks (educational) and plan

conducting a lesson.

    Learning new material (teacher's lecture with a demonstration of the elements of the Visual Basic programming environment).

As a result of the launch, the main Visual Basic window appears on the screen, in the center of which you see another window - an invitation to start creating a new project

(see picture).

If the prompt does not appear, then click on the File menu item, and then select Add Project from the drop-down menu - and it will appear.

You are prompted to select the type of project you wish to create. As long as we have enough standard type. In the prompt window, on the New tab, click the Standard EXE icon, and then click the Open button. The following picture appears in front of you, indicating that you can start designing ( appearance your pictures may be slightly different):

AT
home screen id – Visual Basic Integrated Environment

1. Visual Basic Integrated Environment

The composition of the integrated environment:

1) program title (Application name, Document name, Control buttons);

2) menu bar (standard and specific groups of commands);

3) toolbar (Standard - includes a number of the most commonly used features that can be found in the menu File , Project , Debug , Run ; Edit - used when working with program code; Debug - used to test the program and fix bugs; Form Editor - used to resize, move and align controls on a form);

4) form designer window (workspace for designing the form layout and elements located on it;

5) the Project Explorer window (represents a reflection of the project structure);

6) ToolBox control panel (an overview of the main controls is given below);

7) project properties window (Properties);



isual B

2. Place objects on the form, for example a form or

Well, let's start the assembly. Let's take button(CommandButton) and place it on the form. To do this, click on the button, and then draw a small "frame" inside the form with the mouse. What does it mean to draw a "frame"? This means placing the mouse cursor somewhere inside the form, pressing the left mouse button and, without releasing the key, "drag" the mouse a little obliquely. In this case, a "frame" will drag behind the cursor. Release the mouse. A button labeled Command1 will appear in place of the frame.

Along the edges of the button you will see 8 black squares - markers size changes. If you click on the form past the button, they will disappear, if you click on the button again, they will appear. Just don't double click yet. Drag any of the markers with the mouse - the size of the button will change. You can drag the button around the form if you grab the mouse not on the marker, but on any place inside the button. To destroy a button, right-click on it and in the pop-up context menu select the Delete option. Do it all. And now, if you destroyed it, then create it again.

In the same way, we place an object on the form text field(textbox). Now we have two objects on the form.

3. We write the program

Let's come up with a task for our project. Let something happen on the screen when you press a button. Let's tell the computer to change the color of the form to red when the button is clicked. The command (operator) for this is written like this:

Form1 . BackColor = vbRed

Let's see what is written here.

Form1 is the name of our form (Visual Basic gave it and we won't change it for now)

BackColor - translates as "background color", that is, this is the color that the form is painted with (while it is gray)

vbRed is the color red (Red is red, vb is Visual Basic)

Thus, our operator can be translated as follows:

Form1 . color = red

To the left of the dot we write the name of the object, to the right of the dot we write its name. property, and to the right of the equal sign is the value of that property. Dot must be written.

Visual Basic will take our statement as an order to change the color of the form to red. Now how can we make the computer execute this statement exactly when the button is pressed, and not at some other moment? Sit down at the computer. Pro-

believe if we are in design mode. Double click on the Command1 button. A new window will appear in front of you - a program code window or simply code window. So that we do not get confused, the title of the window contains

word (Code).

The code window should now look like this:

Click the Start button.

The familiar form view with a button and a text box reappears on the screen. Click on the button - the form turns red.

Congratulations! Your first project is up and running.

If you want to start a new project then run File- new project.

III. Independent work

1. Separately selecting each control on the form of your first project, familiarize yourself with their main properties (in the Properties window - on the left).

2. Moving each element with the mouse pointer, change the position of the elements on the form,

3. Add a Label control and set its Caption property to “My first program”.

V. Lesson summary

At the lesson, the first ideas about the programming environment in the Visual Basic language were obtained. To create a project, you must select a form and set the necessary controls on it, the actions of which are described by the program code. Forms are the basics GUI applications. Forms contain objects that allow the user to manipulate data and control the application.

VI. Homework

    Prepare a presentation in subgroups on the topic: “Visual Basic Integration Environment”

Note: when studying new material, students make the necessary entries in a notebook under the guidance of a teacher.

Today we will look at the Line() method using an example program in which horizontal and vertical hatches are drawn when clicking on a shape.

First, let's create a new project. Click "File", " New project" and select "Standard EXE" (Figure 1).

Figure 1 - Project selection

An empty form "Form1" of the new project will appear on the screen (Figure 2).


Figure 2 - Empty form of the new project

Double click on the form. A code editor window will open. Select the Form_Click() procedure (Figure 3).


Figure 3 - Code editor window

To fill the form with vertical lines, you need to place the Line() method in a For loop. We will loop from 1 to 20000 with an interval of 100. The x variable will change (by analogy, the X coordinate, since it is it that changes when the vertical lines move). Here is the resulting program code:

Private Sub Form_Click() For x=1 To 20000 Step 100 Line (x,1)-(x,20000) Next x End Sub
Run the project and click on the form. The result is visible in Figure 4.


Figure 4 - The result of the above code

To also display horizontal hatching on the form, we will introduce another cycle by analogy, only now we will change the Y coordinate. The code of the new cycle looks like this:

For y = 1 To 20000 Step 100 Line (1, y)-(20000, y) Next y
The result of the work of two loops with the Line() methods is shown in Figure 5.


Figure 5 - The result of two cycles

If you want to spruce up the lines with a color, add the color you want, separated by a comma after the Line() method. For example:

Line (x, 1)-(x, 20000), vbGreen or Line (1, y)-(20000, y), vbGreen
The result of the color transformation is shown in Figure 6.


Figure 6 - Result of color transformation

Name Visual Basic (VB) speaks for itself, indicating that it embodies the visual style of programming and Visual- programs do not write traditional programming methods but design from a set of special objects in the form of Windows applications. In other words, to create an application in the high-level visual algorithmic language Visual Basic means to develop a full-fledged graphical Windows application.

Word " Basic » in the name VB indicates only that the syntax of programs and its operators include and develop further a convenient vocabulary of the language Basic (B eginners A llpurpose S ymbolic I instruction C ode). But if you know the usual QBasic, then very soon make sure that Visual Basic very different from it, and in the VB.NET version it is on a par with C++ ,C# ,Java, and other new visual languages.

When asked what is IDEI integrated D development E nvironment) - Visual Basic Integrated Development Environment - compiler or interpreter, you can get the answer: "Both".

Idea Visual Basic as interpreter

The main feature of the development environment software applications (PP)- as interpreter is that the programs created in it are executed only in the development environment itself. The program can be run directly from the environment and if there are errors in it, they are immediately recognized. All this is observed in the Visual Basic IDE, where you can run the application directly. At the same time, Visual Basic uses the Threated-p-Code technology, in which each entered line of code is converted into an intermediate code - Threated-p-Code. This is an interpreter-independent intermediate machine code that runs faster than running with a regular interpreter.

At the same time, Visual Basic immediately checks the syntax of the program and issues a message about the detected error. Another advantage of this technology is the ability to easily find errors in debug mode.

However, Visual Basic also provides the ability to create executable *.EXE files, so it can also be classified as a compiler.

Idea Visual Basic as compiler

Visual Basic 6.0 cannot be called a pure compiler because, unlike, for example, Visual C++, Visual Basic does not create an executable file immediately when launched from the development environment. To create such a file, you must do it explicitly (run the command File\Make *.EXE). The so-called "Native Compiler" - the compiler, at the same time, creates machine code. Thus, Visual Basic combines the capabilities of both the interpreter and the compiler.

Various editions of Visual Basic :

    Beginner Edition(Learning Edition)

Visual Basic Beginner's Edition (former standard) is intended for inexperienced programmers. This edition provides only the basic features for creating applications and basic set controls.

    Edition for professionals(Professional Edition)

The Professional Edition provides more of the tools and support that professional programmers need. It contains a number of additional controls, provides advanced capabilities for accessing databases and creating OLE server applications.

    Industrial edition(Enterprise Edition)

The Industrial Edition is an extension of the Professional edition for enterprise system developers. This edition includes a large number of controls and tools that allow you to develop not only single-user programs, but also complex client-server applications. The production edition also contains a number of special tools (eg Visual Source Safe for version comparison and project management). Using ODBC drivers provides optimized access to external databases. Another one of the additions is the server developer version Microsoft SQL and Microsoft Transaction Server.

The goal of modern secondary education is to develop key competencies in students. The key competencies include one of the most important skills - the ability to live in the information world. For social adaptation and professional self-determination, modern schoolchildren need skills in personal computer, various programming languages, the ability to create projects in various programming environments.

This program has the following goals:

1. Give students a concept of the Visual Basic programming language.

2. Familiarize yourself with the constituent elements of the Visual Basic programming environment.

3. Give skills to create projects in this programming environment.

This program meets the challenges of modern school education performing educational, educational and developmental tasks.

The main educational objectives of this project:

  • Learn the Visual Basic programming language.
  • Teach students how to work in the Visual Basic programming environment;
  • To give basic skills for creating projects in this programming environment;

The main educational tasks of the project:

  • To educate students in personal qualities that contribute to successful social adaptation: purposefulness, objectivity in self-esteem, responsibility, cognitive interest.

The main development tasks of the project:

  • To form in students key competencies that contribute to successful social adaptation;
  • To develop the desire for self-development and personal growth through cognitive activity.

The Visual Basic learning program is based on a consistent and logical system of lessons. The system of lessons for learning the Visual Basic programming language includes six lessons, each of which has its own goals and objectives and gradually solves the main task: teaching a new Visual Basic programming language.

Lesson #1 Topic: Visual Basic programming language. Loading the Visual Basic 6.0 program. Acquaintance with the constituent elements of this programming environment. Review and analysis of the proposed project.

Lesson number 2. Topic: Visual Basic programming language. Creating a simple project in the Visual Basic environment.

Lesson number 3. Topic: Visual Basic programming language. Creation of projects in this programming environment.

Lesson number 4. Topic: Visual Basic programming language. Create a project to perform calculations with the teacher, and then independently work on creating a project.

Lesson number 5. Topic: Visual Basic programming language. Working with user procedures and functions.

Lesson number 6. Topic: Visual Basic programming language. Working with arrays.

This system of lessons uses various forms of education (individual, group), various teaching methods (theoretical, practical, project), various forms of work (lecture, independent work educational nature with subsequent self-examination, frontal survey, project creation).

This system of lessons is proposed for testing in the 11th grade of a secondary school, subject to the availability of an informatics room with personal computers and tool system Microsoft Visual Studio Visual Basic 6.0.

Liked the article? Share with friends!
Was this article helpful?
Yes
Not
Thanks for your feedback!
Something went wrong and your vote was not counted.
Thank you. Your message has been sent
Did you find an error in the text?
Select it, click Ctrl+Enter and we'll fix it!