2011-11-23 30 views

回答

1

的警告信息:後藤的項目設計編譯標籤:http://msdn.microsoft.com/en-us/library/87x5f80y(v=vs.80).aspx

如何隱藏或把它當作錯誤信息。

注意:您創建的對象類型有差異。在下面的例子中,只有test1會發出警告,而不是test2的功能。

Function test1() As String 

End Function 

Function test2() As Integer 

End Function 

您還可以使用編譯器選項來隱藏警告或將它們威脅爲錯誤。這種特定的警告有ID 42105: 功能或操作員沒有返回值警告它是如何在這裏工作

Generated when the function does not have a return value specified. Default for new projects is on. ID: 42105 function

的更多信息:http://msdn.microsoft.com/en-us/library/3y20cc1z(v=vs.80).aspx

When Option Strict is set to Off, Option Strict related warnings cannot be treated independently of each other. When Option Strict is set to On, the associated warnings are treated as errors, no matter what their status is. When Option Strict is set to Custom by specifying /optionstrict:custom in the command line compiler, Option Strict warnings can be toggled on or off independently.

+0

我正在使用VS2010,並且我的* * *上面的例子都是 –

+0

ok。我在VS 2008中進行了測試。也許這兩個版本之間存在差異.. – Stefan

+0

由於@Matt在您的問題中提出了問題,您能否提供一個不觸發警告的示例?這些通常由程序員在函數中和Catch部分中使用Try/Catch塊「錯過」,只是將錯誤拋出調用方法,而不是實際向其返回值。如果你真的想擺脫它們,你必須在Try/Catch塊之後添加一些Return語句。 – Chris

相關問題