Option Strict on by default in VB.NET
In Visual Studio, go menu Tools -> Options -> Projects and Solutions -> VB defaults -> Option Strict. Set it to “On”. Every time you create a new project, it will have Option Strict On by default.
In Visual Studio, go menu Tools -> Options -> Projects and Solutions -> VB defaults -> Option Strict. Set it to “On”. Every time you create a new project, it will have Option Strict On by default.
Here is the most common gotcha. Z = iif(y=0, 0, x/y) ‘Throws a divide by zero exception when y is 0 Don’t use it to avoid division by zero errors. Another possible logic bug is when one side of the iif or the other calls a method that modifies the system state or has output … Read more
In VB.NET: Dim webClient As New System.Net.WebClient Dim result As String = webClient.DownloadString(“http://api.hostip.info/?ip=68.180.206.184”) In C#: System.Net.WebClient webClient = new System.Net.WebClient(); string result = webClient.DownloadString(“http://api.hostip.info/?ip=68.180.206.184”);
I’ve run into this error dozens of times: Cause Security permissions were not properly set when the Oracle client was installed on Windows with NTFS. The result of this is that content of the ORACLE_HOME directory is not visible to Authenticated Users on the machine; this causes an error while the System.Data.OracleClient is communicating with … Read more
VBA doesn’t support class polymorphism so I recommend to change the way you’re thinking about the Employee and Manager classes. You can’t have an Employee class as a base class and then a separate Manager class that derives from Employee. They could be 2 separate classes implementing a common interface. I will talk about it … Read more
The problem: A Bitmap, with a size that is much smaller than the container used to show it, is blurred and the otherwise sharp edges of the well-defined areas of color are unceremoniously blended. This is just the result of a Bilinear filter applied to a really small image (a few pixels) when zoomed in. … Read more
First read this: Use of Application.DoEvents() So after reading the above answer you will never using DoEvents ever again, and without the DoEvents (and/or Invalidating the ProgressBar so its Paint event will fire) the “progressbar won’t animate since the upgrade process is so intensive” Hence Cthulhu’s comment – “You can make a dialog with a … Read more
I’ve got an article on this very topic. In summary (copied from the bottom of the page): Definitely use StringBuilder when you’re concatenating in a non-trivial loop – especially if you don’t know for sure (at compile time) how many iterations you’ll make through the loop. For example, reading a file a character at a … Read more
I think you’re confusing the concept of references vs. value types and ByVal vs. ByRef. Even though their names are a bit misleading, they are orthogonal issues. ByVal in VB.NET means that a copy of the provided value will be sent to the function. For value types (Integer, Single, etc.) this will provide a shallow … Read more
OrElse is a short-circuiting operator, Or is not. By the definition of the boolean ‘or’ operator, if the first term is True then the whole is definitely true – so we don’t need to evaluate the second term. OrElse knows this, so doesn’t try and evaluate temp = 0 once it’s established that temp Is … Read more