Use VB. NET to develop pure. Net Applications

Source: Internet
Author: User

Many companies I have worked for are selecting VB. net, as their core development tool, has gone through a long period of time. One of their major concerns is that if they do not use the C # language, they cannot develop pure. net Framework code. There are two main reasons for them to come to the conclusion that, first of all, due to the running restrictions of VB (6.0 or earlier versions), VB is not as powerful as C in Developing COM components, they are concerned about whether these restrictions exist.. the main development tool on the net platform, many VB developers suspect that Microsoft is already in VB.. Net has improved the functions of earlier versions of VB.

A customer once raised this question with me and also specifically asked me to help his company use VB. NET as a pure. NET development language without any function in VB6. When I asked him why he thought VB. net is not pure. when developing the language, he told me that he recently upgraded a project from VB6 to VB. net, in VB. net. visual Basic and imports Microsoft. visualBasic. compatibilit input statements, which indicate VB. net is still using some functions of earlier VB versions; he said, "If VB. net is. in the. NET environment, why does a stream of development languages need to use functions in earlier VB versions? ". In order to answer this question, and to VB. NET developers provide a suggestion on how to use these packages. I will explain in this article why Microsoft is still working. NET platform to implement some functions in earlier versions of VB.

Core dynamic link library (DLL) in VB)

The method for building the core VB language into the. NET Framework is the same as that of C #. The main difference is that Microsoft adds two additional libraries to. Net for VB developers. First, Microsoft. visual Basic is. net, which is an important part of the redistribution package. It is a feature of earlier versions of VB. net, and the two are also slightly different. In fact, some VB functions (especially those in type conversion) provide better performance than the objects provided by. Net Universal Language Runtime (CLR. For example, using CINT () is better than using a convert object. In addition, some VB functions do some additional work for you, such as the CSTR () function () when you convert a string, it also performs regional processing automatically. If you use a convert object, you must do this extra work on your own.

At the same time, the library in. Net also provides some common environment constants that are frequently used by VB developers, such as vbcrlf carriage return line breaks. In fact, if you do not want to use the old-fashioned constants, you can use system. environment. newline method or system. convert. tochar (13) & system. convert. tochar (10) to get the same constant. Constant references such as vbcrlf are directly mirrored to the underlying calling of the Framework in. net, so there should be no impact on performance. In this case, the compiler optimizes it into a single string. If it is a variable, it is directly mapped to rn and translated into a carriage return line break. Functions in earlier versions of VB are also directly mapped. NET framework underlying calls, such as msgbox statements directly mapped.. NET Framework. In this case, the intermediate language (IL) generated after compilation is basically the same, so there is almost no impact on the performance.

Some features in earlier versions of VB, such as the inputbox function, the control array, and the support for ADO in the. NET Framework, were not directly equivalent. However, for these features that cannot be directly supported, Microsoft provides another feature named Microsoft. visualBasic. compatibility library, which is used to make. NET provides downward compatibility, so if your VB application is not upgraded, do not use the functions. Microsoft. VisualBasic. Compatibility supports controlling arrays, Environment functions, and font conversion. Another database provided by Microsoft, Microsoft. VisualBasic. Compatibility. Data, supports ADO objects, interfaces, and methods. This database can be used to manipulate databases like ADO in earlier VB versions. You should pay attention to the warning information of vs. NET Help Files about whether you should spend time and effort learning the functions of these old versions.

"Warning: When you use Visual Basic. NET development. NET applications, it is best not to use Visual Basic. the functions provided in the compatibility namespace may not be supported in future VB versions.. net."

It can be seen that in the use of VB. net, you should note that you can use those functions in earlier versions of VB, not those functions, not available.. net. After understanding this, you can use some functions in earlier versions of VB and develop pure. NET applications. Therefore, you do not have to create a pure.. Net Applications discard years of training investment and practical experience in VB and use C #, because VB. net can also be used.. NET Framework provides all functions for C. In fact, I once recommended to my customers not to use the Upgrade Wizard provided by Microsoft, because the Wizard will. the backward compatible libraries provided in. NET are added.. Net project, so it should be constructed directly.. NET application, and then port the code from the original application to the new application.. net new functions are not replaced. net supports old-fashioned features, so that the developed applications will be pure.. NET application.

Microsoft. VisualBasic supports pure. Net Applications

Microsoft VisualBasic is the implementation of the VB language in the. NET Framework. It provides functions Based on. NET, not just for compatibility with earlier versions of VB. In.. Net project. the imports Statement of Visual Basic does not affect the performance. The main function is to tell the compiler where to find the called code after you use the relevant functions.

The. NET Framework retains the Microsoft. VisualBasic package for a long time and can always be released again. As VB. A member of the net product group said, "You cannot delete Microsoft. visualBasic. DLL. The functions in this dynamic link library are not left behind by earlier versions of VB. net has been re-implemented, and is well known by VB developers, with forward compatibility, so using it will not do any harm to the application. Finally, if you reuse the code in the VB example, you will also use these features. Deleting this dynamic link library does not allow you to develop more pure. NET applications. you just lose some useful classes ."

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.