You can add a preprocessor directive to cause an error at compile time in C# like this:
#error This will cause a divide by zero
How can I do the same as this in vb.net?
or
Is there another way to create an error that provides custom helpful information in the Errorlist.
TLDR: I want to do something like THIS in VB.NET:
To display the Error List, choose View > Error List, or press Ctrl+\+E.
In Visual Studio, go to the menu bar and choose Help > Send Feedback > Report a Problem, or submit a suggestion by using Help > Send Feedback > Send a Suggestion.
Run-time errors are those that appear only after you compile and run your code. These involve code that may appear to be correct in that it has no syntax errors, but that will not execute. For example, you might correctly write a line of code to open a file.
There is no equivalent to
#error
in VB.Net
I have found no way to add a meaningful error to prevent compiling.
You can also declare a var with sure compiler error such as:
Dim error As String = "This is as useful a description as your gonna get"
thus avoiding all the underscores. That will result automatically in a compiling error ("Keyword is not valid as an identifier"), not a warning.
Example:
#if _A_DEPRECATED_DEFINE_
DIM error As String = "remove the define: is deprecated!"
#end if
Here is one way that you can achieve what you want. It is not perfect. But it does meet your criteria of:
You first need to declare a variable with the custom text you want displayed with underscores in between each word. (Yes the underscores are annoying but they are necessary)
Dim This_is_as_useful_a_description_as_your_gonna_get as String
This creates an unused variable. which in conjunction with the IDE's ability to treat warnings as errors will give you something close to what you are looking for:
You can turn on treat warnings as errors by going to your project properties and the compile tab. like so:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With