Visual Basic

Computer programming language
open 6 entries with the same name
Collection
zero Useful+1
zero
synonym VB (Visual Basic programming language) generally refers to Visual Basic (computer programming language)
Visual Basic (VB for short) is Microsoft Developed object-oriented Of programing language Use Visual Basic to quickly and easily create type safe .NET Application. [4]
"Visual" refers to the development of graphical user interfaces( GUI )Method of interface element You can simply add the pre established object to a point on the screen. "Basic" means BASIC (Beginners All Purpose Symbolic Instruction Code) language is a kind of technological development The most widely used language in history.
Visual Basic is derived from BASIC programing language VB has a graphical user interface( GUI )And fast application program Development (RAD) system, which can be easily used DAO RDO ADO Connect to the database or easily create Active X controls for efficient generation Type safety And object-oriented applications [2] Programmers can easily use the components provided by VB to quickly build an application.
Software name
Visual Basic
software platform
.NET
Online time
April 1991
Last updated
September 22, 2022 [5]
Software language
Visual Basic
Developers
Microsoft
Software Licensing
Microsoft
Software version
Visual Basic 16.9 [5]
Software size
188 MB

Background

Announce
edit
VB 6.0 Startup Screen
In April 1991, Microsoft The company has launched the Visual Basic 1.0 Windows version. This connection programing language and user interface The progress of is called Tripod (sometimes called Tripod Ruby ), originally designed by Alan Cooper (Alan Cooper). At that time, it was the first "visual" programming software. [1] [3]
Over the years, Visual Basic has undergone several developments, and its development history is shown in the "Brief History of Visual Basic Development" table.
On March 11, 2020, Microsoft Announces that VB will not be developed or added.
A Brief History of Visual Basic
Release date
name
explain
Before. NET Framework was introduced
1991-04
Visual Basic 1.0 for Windows
1992-09
Visual Basic 1.0 DOS version
1992-11
Visual Basic 2.0
The interface and speed of the previous version have been improved.
1993-06
Visual Basic 3.0
It includes a data engine that can directly read the Access database.
1995-08
Visual Basic 4.0
32-bit and 16 bit versions have been released. It includes support for classes.
1997-02
Visual Basic 5.0
It includes support for user-defined controls, and from this version, VB can support Chinese.
1998-10
Visual Basic 6.0
After the introduction of. NET Framework
2002-02
Visual Basic .NET 2002 (7.0)
Because it uses new cores and features, many VB programmers have to rewrite the program.
2003-04
Visual Basic .NET 2003 (7.1)
It mainly improves the operation status, improves the IDE and runtime stability.
2005-11
Visual Basic 2005 (8.0)
This is a major change in vb. net. Microsoft has decided to remove the ". NET" part from its name. VB2005 provides new language features such as My pseudo namespace, generics, and operator overloading.
2007-11
Visual Basic 2008 (9.0)
It supports IIF functions, anonymous classes, LINQ, lambda expressions, XML data structures and other new language features.
2008-03
Microsoft announced the end of extended support for VB 6.0.
2010-04
Visual Studio 2010 (10.0)
It provides new language features such as support for Dynamic Language Runtime (DLR), automatic implementation of properties, collection initialization, and no need to enter underscore "_" when writing code line breaks.
2012-05
Visual Studio 2012 (11.0) RC
It provides new language features such as supporting easier asynchronous programming, Iterator, and expanding Global keywords.
2013-11-13-2
Visual Studio 2013
2014-11-13
Visual Studio 2015
Windows, iOS and Android application development

Language features

Announce
edit
Creating application installation disks provides users with friendly Integrated development environment , specifically shown in:
Visual Design platform : When programming with traditional programming languages, it is generally necessary to design the application interface (such as the appearance and location of the interface) by writing programs, and the actual effect of the interface cannot be seen in the design process. In Visual Basic 6.0 Object-oriented programming method (Object Oriented Programming) Data encapsulation As an object, each object is visible. Developers in Interface design You can directly use the toolbox of Visual Basic 6.0 to "draw" different types of objects on the screen, such as windows, menus, command keys, and set properties for each object. All developers need to do is write code for the object to complete the event process, so the efficiency of program design can be greatly improved.
event driven Programming mechanism of: Process oriented The program of main program And several subroutine And functions. When the program runs, it always starts from the main program, and the main program calls subprograms and functions. The developer must determine the execution order of the entire program in advance when programming. The event driven programming of Visual Basic 6.0 is to code the events related to an object triggered by the user, and each event can drive the running of a program. Developers only need to write code that responds to user actions. Such application code is simple and easy to write and maintain.
Structured Programming language : Visual Basic 6.0 has rich data type And numerous intrinsic functions. It uses modular and Structured programming language , clear structure, simple grammar, easy to learn.
Powerful database function : Visual Basic 6.0 can access Access, FoxPro, etc. by using data controls database system , you can also access Excel , Lotus, etc Spreadsheet
ActiveX Technology: ActiveX has developed the original OLE Visual Basic 6.0 can develop sound, image, animation Word processing , spreadsheet, Web and other objects in one application.
Network function : DHTML provided by Visual Basic 6.0( dynamic html design tool It enables developers to dynamically create and edit Web pages, enabling users to develop multi-functional Network application software

Fundamentals of Language

Announce
edit

Annotation method

In VB, there are two ways to annotate.
1. Start with the Rem keyword, and add a space between the Rem keyword and the comment content. Comments can be a single line or written after other statement lines. If you use the Rem keyword after another statement line, you must use the colon (:) is separated from the statement.
2. Use one apostrophe (') instead of the Rem keyword. If an apostrophe is used, it is not necessary to add a colon when using it on other statement lines.

Feature measurement

In Visual Basic, you can use the attribute method and event To describe and measure the characteristics of an object.
Event
An event is something that happens to an object. Events can also be divided into mouse events and keyboard events. For example, in Command button (Command Button) Possible Mouse events such as click, mouse move, mouse down, and keyboard events such as key down may also occur. In a word, events indicate the object "under what circumstances?", and are often used to define the time and condition for an object to reflect.
Method
The method is used to control object Function and operation of Internal procedures For example, people have the functions of speaking, walking, learning, sleeping, etc. In Visual Basic, the functions and operations that objects can provide are called "methods". Take the form as an example. It has a method of showing or hiding. In a word, methods specify "what can an object do?" and are often used to define the function and operation of an object.
Property
Attributes refer to some indicators used to describe the name, position, color, font and other characteristics of an object. You can change the properties of objects through attributes.
Some properties can be set through the property window during design without writing any code; Some properties must be set while running the program by writing code. You can use the Runtime The properties read and set become read-write properties, and the properties that can only be read become read-only properties. In short, attributes indicate "what is an object like?" and are often used to define the appearance of an object.

Objects and Classes

Object
Visual Basic.NET has“ object-oriented ”The basic unit of Visual Basic.NET application program is object NET programming is to assemble programs with "objects". This kind of "object-oriented" programming method is very different from the traditional method of all code programming, just like using Integrated circuit chip Assembling TV sets triode diode The difference between assembling TV sets is the same. Obviously, the "object-oriented" programming method is simpler and more convenient than the traditional programming method, and the program written is more stable. Therefore, "object" can be regarded as Visual Basic NET program design.
In Visual Basic NET programming, the object can also include the head, hands, legs, feet and other parts, each of which can be taken as a separate object to be studied. In Visual Basic NET programming, the entire application program It is an object, and the application contains a form, Command button (Command), menu and other objects.
Class
In Visual Basic NET, objects are created by classes, so objects can be said to be concrete instances of classes, which is like the relationship between cake and cake making mold.
Different objects belong to different kinds. Objects of the same class may have some different characteristics (or objects of the same class may not have the same characteristics); Objects with the same characteristics are not necessarily the same kind of objects, which is like people and monkey Although both have the characteristics of height and gender, there are still differences in IQ, language and other characteristics between the two objects. These two objects have many differences in characteristics, and they cannot be regarded as the same type of objects at all. Although men and women have gender and physiological differences, most of them have the same characteristics and can be regarded as the same kind. Thus, it can be summed up in one sentence: most of the characteristics of objects of the same type are the same.

Related Controls

According to the application type, Visual Basic controls can be divided into the following three categories:
Built in controls
The built-in controls are the controls in the Visual Basic toolbox, which contain the controls required by common form programs
In Visual Basic, most program execution is completed in events.
In the code, each event of the control needs to be declared, and the declaration method is similar to the declaration of a subprocess. Most controls will automatically complete the declaration of the most common events of the control when you double-click the control to enter the code interface. Specific code examples are as follows:
ActiveX controls include controls provided by different versions of Visual Basic and professional edition , the controls provided in Enterprise Edition, and the controls provided by third parties. ActiveX control is an extension of the built-in control of Visual Basic. Developers can Personal needs Expand freely, and the expanded ActiveX control will be displayed in the toolbox.
insertable object
In Visual Basic's toolbar Other third-party objects can be placed in, which can be used as easily as controls. The added objects are also displayed in the toolbox. For third-party objects, you can download controls from trusted sources and import them by adding references. The controls that support these customized Vbs are: ComponentOne Studio , Spread ActiveReports , MultiRow, etc.

Language characteristics

Announce
edit

Basic characteristics

The central idea of VB is to facilitate the use of programmers, whether novices or experts. VB uses a GUI system that can easily establish application programs, but can also develop quite complex programs. VB program is a combination of visual component arrangement based on forms, and code is added to specify the properties and methods of components. Because some default properties and methods are already defined in components, programmers can complete a simple program without writing much code. In the past version, the performance problem of VB program has been put on the desktop, but with the rapid increase of computer speed, the debate about performance has become less and less.
form controls The addition and change of can be realized by drag and drop technology. A toolbox full of controls is used to display available controls (such as Text Box Or button) Attribute value It will be provided when the control is created, but the programmer can also make changes. 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 window size change event. When the user changes the window size 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 input the text Automatic translation Or block the input of some characters.
VB programs can include one or more forms, or a main form and multiple subforms, similar to the operating system. Dialog windows with few functions (such as forms without maximize and minimize buttons) can be used to provide pop-up functions.
VB components can both have user interface , or not. In this way, the server-side program can handle the added modules.
VB uses the method of parameter calculation garbage collection This method contains a large number of objects, providing basic object-oriented support. Because more and more components appear, programmers can choose the extension libraries they need. Unlike some languages, VB is insensitive to case, but can automatically convert keywords to standard case status, and force Symbol table The variable name of the entry entity follows the writing rules. By default character string The comparison of is case sensitive, but this function can be turned off.
VB makes a large number of external controls have their own living space a large number of Third party controls Provided for VB. VB also provides methods to establish, use and reuse these controls, but because of language problems, it is not easy to create another from one application.

Language shortcomings

The Visual Basic language has Inheritance is not supported No native support Multithreading exception handling Three obvious shortcomings, such as imperfection, make it limited (these shortcomings have been improved in vb. net).
Inheritance is not supported
VB 5.0 and VB 6.0 are both Object based Of programing language , but does not contain inherited properties. VB provides special class functions, but still can not meet the needs of programmers.
No native support for multithreading
Visual Basic has no native support for multithreading and can only use Windows API And extremely unstable. Because in API The thread created is not initialized automatically Runtime Library , some functions cannot be used. General, in VB6 And other early VB development environment Under, the purpose of using API to create threads is to complete the calculation of a large amount of data or logic that is easy to make the program suspended.
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 to clearly write the reason for the error, and then the program will terminate.
Err. can be used in Visual Basic Raise Throw an exception There are two common modes for handling exceptions thrown by the system and users: one is to use On Error Resume Next processing error; The other is to use On Error Goto Introduce operation error handling code. But compared with C++and other languages exception handling Destroyed the code structure.

Derived language

Announce
edit
Microsoft has developed a series of languages derived from Visual Basic:

VBA

Visual Basic for Applications( VBA ): Included in Microsoft applications (e.g Microsoft Office ), and third-party products like WordPerfect and Office. It seems contradictory that VBA is embedded in various applications, but its function is as powerful as VB.

VBS

VBScript (VBS): It is the default ASP language and can also be used in Windows Scripting and Web page encoding Medium. Although its syntax is similar to VB, it is a completely different language. VBS does not use VB Runtime Run by the Windows Script Host Interpretation and implementation The differences between these two languages affect the performance of ASP websites.

vb.net

Visual Basic.net (vb. net): When Microsoft plans to develop a new programming tool, the first decision is to use VB 6.0 to change the old one, or to rebuild the project to develop new tools. Microsoft later developed Visual Basic.net, the successor of VB, which is also part of the. net platform. Vb.net programming language is a real object-oriented Programming language, and VB is not fully compatible.
Visual Basic.net (vb.net) is a new generation of VB language. It is not just a simple upgrade of VB 6.0. There is a big difference between vb.net and VB (generally referring to the version before VB 6.0). Its new features are mainly shown in the following aspects:
1. vb.net is fully integrated into Visual Studio In the integrated development environment, there are some differences between this integrated development environment and VB in several aspects. It is mainly reflected in the form layout and menu.
2. The vb.net project is different from VB. It uses a folder based model, and all projects are placed in the project folder hierarchical structure Medium.
3. Used in vb.net ado.net To access the database. ado. net is part of the. net Framework. There are two main ways to realize data access in vb.net: one is to Programming stage By creating and configuring data adapters DataAdapter And build data set DataSet The second is to dynamically create configuration through programming during operation Data adapter And create and generate data sets.
4. It is used in vb.net asp.net Technology to write Web pages. stay asp It is not used in. net scripting language , but a real programming language. With the Web based functions of asp. net such as Web applications and XML Web Services, the development of Web pages by vb. net is very similar to the development of Windows applications, and the Web page code is also orderly.
5. vb.net has become a completely object-oriented programming language, and more language features have been added.
Visual Basic.net A conversion wizard is provided to help developers convert VB 6.0 program code to the corresponding program code of vb.net.

Language dispute

Announce
edit
It is not uncommon for programmers to argue about the advantages and disadvantages of various languages, and Visual Basic has become a language full of controversy.

Opposite views

Some critics believe that Visual Basic is a language for children and novice programmers. It has been a simple language since its design. Some C++and Java The properties in do not appear in VB. While feeling the convenience and speed of development, some are similar to Compile time Type and declaration checking is turned off by default. Some programmers exclaim that VB is easy to use, and look at some errors like "undefined type" in frustration.
Some critics believe that the simplicity of Visual Basic makes it harmful in the future. Many people learned VB by themselves, but did not learn good programming habits. When VB enters the classroom, students will not learn many basic program technologies and structures, because many technologies have been included in the components visible to users. There is no need to learn the standard programming habits. Because VB has a visual feature, it leads to some inexplicable code. In addition, many error and warning checks are turned off by default, making it difficult for programmers to find hidden errors. Experienced programmers will open these options when programming with VB.
Some critics criticize Microsoft Simply copied BASIC To Visual Basic.
Programs developed by Visual Basic can only run in Microsoft Windows Medium; VB is also required for runtime Runtime
Visual Basic is not a good foundation for Windows API In many cases, "tricks" of low-level operations are used for programming. The low-level memory operation of C language is much simpler than that of VB.
VB language as computer language The introduction of VB is an entry-level language for many students to learn programming. College students use VB language to start their computer learning world.

Orthodox viewpoint

All tools are invented for different tasks, like swords and Hoe , sword master is not necessarily do hoeing Expert, sword expert can't produce food to feed people except killing people, so any tool discrimination is wrong. The power of Visual Basic is that it can quickly develop enterprise software, so that programmers have more time and energy to consider the needs of users and produce software that meets the needs of users. It is especially suitable for the development of large-scale enterprise software, such as MIS 、MRP、 MRP II ERP Such heavyweight software, rather than spending a long time to make a DLL with only a few kilos.
The biggest advantage of Visual Basic is its ease of use, which enables experienced VB programmers or those who just know the basics to use their own methods quickly Development program And VB program can be very simple and database connection. For example, you can bind the database with controls, so that the program written in VB can master all the information of the database without writing a line of code.
Although programs developed by Visual Basic are only natively supported in Microsoft Windows Linux There are some projects in these platforms, making it possible to use Visual Basic code to compile successfully on these platforms.
Programs developed in any language need to be supported by a certain runtime environment software system For example, it is normal to need support, which is called "standing on the shoulders of giants". Programs developed by traditional Visual Basic need VB Runtime Support; Visual Basic .NET The developed program (such as C #) needs Net Framework support; Java developed programs need the support of Java virtual machine.