Introduction to some programming languages—Visual Basic language

Introduction to some programming languages—Visual Basic language

Visual Basic language

Introduction

Visual Basic (VB for short) was developed by the American Microsoft Corporation in 1991.Developed in 1991 , a development tool based on a graphical user interface under the Windows environment is an object-oriented, visual new development tool that can run under all Windows environments including Windows98 and WindowsNT.
  
Visual Basic uses its event-driven programming mechanism and novel and easy-to-use visual design tools, and uses Windows internal application program interface functions, and uses technologies such as dynamic link libraries, dynamic data exchange, object linking and embedding, and open database access. Efficiently and quickly create an application software system with powerful functions and rich graphical interfaces under the Windows environment.
  
The open database access function is provided in Visual Basic, which can use and operate external databases through direct access or connection. The Visual Basic system itself provides very good data management functions. Using the data manager, users can directly create Access databases, and can also directly edit and access other external databases, such as FoxPro, dBASE and FoxBASE. Through the window designer, you can create data access forms.
  
In terms of table processing, Visual Basic is bundled with Crystal report, which can basically meet the functions required for table processing. Visual Basic is suitable for both application software development and system software development.

Background

1991 1991 1991 44In April , Microsoft released Visual Basic 1.0 for Windows, an advancement that bridged the programming language and user interface called Tripod, originally designed by Alan Cooper. At the time, it was the first "visual" programming software.

Over the next few years, Visual Basic has undergone many developments, and its development process is shown in the "Visual Basic Development Brief History" table.

in 2020 2020March 3, 2020March 1111On the 11th , Microsoft announced that it would no longer develop VB or add functions.

language feature

Visual design platform

When using a traditional programming language to program, it is generally necessary to design the interface of the application program by writing a program, and the actual effect of the interface cannot be seen during the design process. In Visual Basic 6.0, the object-oriented programming method is adopted, and the program and data are encapsulated as an object, and each object is visible. When designing the interface, developers can directly use the toolbox of Visual Basic 6.0 to "draw" different types of objects such as windows, menus, and command buttons on the screen, and set properties for each object. All the developer needs to do is to write codes for the objects that need to complete the event process, so the efficiency of program design can be greatly improved.

Event-driven programming mechanism

A process-oriented program is composed of a main program and several subroutines and functions. When the program is running, it always starts from the main program, and the subroutines and functions are called by the main program. The developer must determine the execution sequence of the entire program in advance when programming. However, the event-driven programming of Visual Basic 6.0 is to code the relevant events triggered by the user for an object, and each event can drive the operation of a program. Developers simply write code that responds to user actions. Such application code is streamlined and relatively easy to write and maintain.

structured programming language

Visual Basic 6.0 has rich data types and numerous built-in functions. It adopts a modular and structured programming language with clear structure, simple syntax and easy learning.

Powerful database function

Visual Basic 6.0 can use data controls to access various database systems such as Access and FoxPro, and can also access various electronic forms such as Excel and Lotus.

ActiveX technology

ActiveX develops the original OLE technology, enabling developers to get rid of the shackles of a specific language, and easily use the functions provided by other applications, so that Visual Basic 6.0 can develop a set of sound, image, animation, word processing, spreadsheet, Web, etc. object in one application.

Internet function

The DHTML design tool provided by Visual Basic 6.0 enables developers to dynamically create and edit Web pages, enabling users to develop multifunctional network application software.

Language Features

Basic Features

A central idea of ​​VB is to make it easy to use for programmers, no matter novice or expert. VB uses a GUI system that can easily build applications, but can develop quite complex programs. VB's program is a combination of form-based visual component arrangements, and the code is added to specify the properties and methods of the components. Because part of the default properties and methods are already defined in the component, programmers can complete a simple program without writing much code. The performance issues of VB programs in the past version have been put on the table, but with the rapid increase of computer speed, the debate about performance has become less and less.

Form controls can be added and changed using drag and drop technology. A toolbox full of controls is used to display the available controls. Each control has its own properties and events. Default property values ​​are provided when the control is created, but can be changed by the programmer. Many attribute values ​​can be changed with user actions and modifications at runtime, thus forming a dynamic program. For example: the code that can change the position of the control is added to the size change event of the form. Whenever the user changes the size of the window at runtime, the control will also change its position accordingly. Add the corresponding code to the text change event in the text box, and the program can automatically translate or prevent the input of certain characters when the text is entered.

A VB program can contain one or more forms, or a main form and multiple subforms, similar to the operating system. Dialog windows with little functionality (such as forms without maximize and minimize buttons) can be used to provide popup functionality.

VB components can either have a user interface or not. This allows the server-side program to handle the added modules.

VB uses the method of parameter calculation to carry out garbage collection, which contains a large number of objects and provides basic object-oriented support. Because of the emergence of more and more components, programmers can choose the extension library they need. Unlike some languages, VB is not case-sensitive, but it can automatically convert keywords to standard case, and force the variable names of entities in symbol table entries to follow the writing rules. String comparisons are case-sensitive by default, but this can be turned off.

VB enables a large number of external controls to have their own living space. A large number of third-party controls are provided for VB. VB also provides ways to create, use, and reuse these controls, but due to language issues, creating one application from another is not straightforward.

Language shortcomings

does not support inheritance

Both VB 5.0 and VB 6.0 are object-based programming languages, but do not include inheritance features. VB provides special class functions, but it still cannot meet the needs of programmers.

No native support for multithreading

Visual Basic has no native support for multi-threading, and it can only be realized by calling Windows API, and it is extremely unstable. Because the runtime library is not automatically initialized in the thread created by the API, some functions cannot be used. Generally, in VB6 and other early VB development environments, the purpose of using API to create threads is to complete a large amount of data or logic calculations that easily cause the program to freeze.

Incomplete exception handling

Visual Basic has built-in exception handling. Even if no exception handling code is written, once the user makes an error, a dialog box will pop up clearly stating the cause of the error, and then the program will terminate.

Visual Basic can use to Err.Raisethrow an exception. There are two commonly used modes for handling exceptions thrown by the system and users: one is to use to On Error Resume Nexthandle errors; the other is to use On Error Gototo introduce execution into error handling code. But compared to languages ​​such as C++, such exception handling destroys the structure of the code.

simple program

Output Hello, World!

Module Hello    
  Sub Main()               
    MsgBox("Hello,World!") 
  End Sub                  
End Module                 

A + B problem

Imports System
Module APlusB
    Sub Main()
        Dim ins As String() = Console.ReadLine().Split(New Char(){" "c})
        Console.WriteLine(Int(ins(0))+Int(ins(1)))
    End Sub
End Module

reference

  • https://baike.baidu.com/item/Visual%20Basic/287852?fr=ge_ala

  • https://learn.microsoft.com/zh-cn/dotnet/visual-basic/

  • https://baike.esnai.com/view.aspx?w=VisualBasic

Guess you like

Origin blog.csdn.net/ZH_qaq/article/details/132303020