VB6 is Visual Basic 6.0, which is the ultimate version before the introduction of. Net framework. This software is an important part of Microsoft Visual Studio 6.0. It appeared in the 1999 "The Matrix" movie, which is the peak of VB6.
After the emergence of. Net framework, it has been gradually used by C# and Visual Basic.net Instead, even at GitHub it is recognized as VBA, VB programmers of course know that VB6 and VBA are different, for example, VB6 can be compiled into EXE files, VBA is run in Excel, but their syntax is similar, code is easy to transplant, similar to ASP and VBS.
So VB6 this has been declining programming language has no use?
If you want to use VB6 to develop web applications, that is to compile DLL to run in ASP, it is basically useless, because it is very difficult to deploy such an environment on IIS after windows 2008.
If you want to use VB6 to develop Windows desktop program with fashionable interface, it is useless, because the UI developed by VB6 is relatively old.
But if you don't require the UI of Windows desktop program, you will find that VB6 has unexpected vitality.
As long as windows has two files msvbvm60.dll and stdole2.tlb in the directory %windir%\system(32-bit) or %windir%\syswow64(64 bit), the EXE compiled by VB6 can run directly. Fortunately, even in the latest version of windows 2019 or windows 10, both 32-bit and 64 bit versions have pre installed these two files, which is obviously better than using the. Net framework The compiled exe files have stronger adaptability in different Windows versions, because the. Net framework pre installed in different Windows versions is different. Some even need to download the installation package to install.
It seems that the EXE file compiled with VB6 is still very beautiful, but to run well on different versions of windows, the following conditions need to be met:
Using the compile to P-code compilation method, the compiled EXE file is smaller and has better compatibility. In addition to WIN98/95/Me and WinNT, it has been tested on the server version of Windows 2000/2003/2008/2012/2016 /2019 and the desktop version of Windows XP/Vista/7/8/8.1/10, which can be run directly without additional preparation.
Do not refer to ActiveX DLLs directly, because the binary versions of these ActiveX DLLs in different versions of windows may not be fully compatible. If they are not compatible, they can not be used. The solution is to use them in the way of CreateObject, which will greatly improve the compatibility. However, use CreateObject In the GUI programming process, you can't think of listing the properties and methods, which is inconvenient to use. The solution is to create an "objectified" class, encapsulate the interface of ActiveX DLL, so that we can partially realize the programming experience of directly referring to ActiveX DLL.
Specific use cases can be found in the PigObjFs repository on my GitHub.
The following is a list of several ActiveX DLLs that come with windows. If you don't need to register with Regsvr32, you can use them in an object-oriented way.
64 bit windows as an example
Microsoft ActiveX Data Objects 6.1 Library
Microsoft Scripting Runtime
Microsoft XML, v6.0
With Windows API functions, most VB6 can be used, and only a few need VC to use them. The similar writing method is as follows:
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Do not use the installation package to make software, because the produced installation package EXE file may not be able to run on different versions of windows, and there are 32-bit and 64 bit differences.
For the use of OCX files, the OCX files used by the program should not be copied to the public directory such as% windir% \ \ system or windir% \ \ syswow64, so as to avoid conflicts with other software. Only store the OCX file compiled by VB6 in the same directory.
After completing the above preparation, the EXE file and OCX file compiled by VB6 are stored in the same directory and compressed into a ZIP file, which can be released and used. On different Windows versions, you just need to UNZIP and run exe directly.