Visual Basic 2005 New Function Reviews - Unusual Assistant

zhaozj2021-02-16  81

In the process of using Visual Basic .NET development, we have the following experience, that is, VB.NET gives the help of compiling errors. Very detailed, it can easily find the problem method, but the runtime error is more For example, we write the following code:

Dim b as buttonb.text = "hello"

When the code is running here, only the following form will be popped up:

A sentence "not set to the object instance" is difficult to fill. For beginners, they don't know what this means, let alone solve the problem. Don't expect the "Help" button to help, he just explains what is called an exception window, the sound is called "interrupt" and so on. Such an exception window is very limited to the development of the help, and he can't even link the documentation about the exception class. Such an exception window is not even as information provided by VB6, which causes more VB6 programmers to encounter hindrances when upgrading to VB.NET. Visual Basic 2005 and C # and J # languages ​​in Visual Studio 2005 have added an exception assistant function to a large extent, which solves this problem. If we enter the above code in VB2005, it will get the following window when running:

This is an abnormal assistant, he is divided into three parts: first provides information attached to the abnormal object like VB.NET, and then two new parts: Troubleshooting TIPS and ACTIONS. TroubleShooting Tips is an unusual help, not just a document of an exception, and there is a guide to a specific language to solve the problem. For example, NullReferenceException provides a Troubleshooting NullReferenceException Exceptions, and its content is exceeded:

Use the New keyword to create the instance. You may have tried to use an object without providing an instance of the object. For example, Dim CustomerTable As DataTable should be rewritten as Dim CustomerTable As New DataTable.

Include a Code Block That Checks for Null References. ProgramMatical CHECK To DETERMINE IF A FUNCTION HAS RETURNED NULL (NOTHINGIN VISUAL BASIC) INSTEAD OF An Instance of An Object.

Explicitly Catch NullreferenceException in a try ... catch ... Finally Statement. A try ... catch ... Finally Statement CaN Check for Specific Types of Exceptions, Going from MOST SPECICICICIFIC TO Least Specific.

This information has been more humane than VB.NET, and it is possible to suggest a null reference check, use the NEW keyword and common means using the TRY sentence.

The exception assistant is very helpful for developers, such as the exception caused by security, is usually very difficult, because many different code can cause the same security anomalies, so that even if the abnormal associated document is also difficult to find out. The abnormal assistant gives a very detailed help, give a large number of links in the Troubleshooting prompt:

转载请注明原文地址:https://www.9cbs.com/read-12197.html

New Post(0)