VB.NET - Reading and writing app.config
· ☕ 2 min read
I found so many articles on the internet suggesting the need to write your own classes to read/write app.config. While the read is fairly easy, people are struggling a lot with the write, some are saying that write is not supported by .NET at all.

VB.NET - Getting Started with Custom Drawing
· ☕ 2 min read
Here I am going to show some basics of custom drawing in VB.NET. This is not production-class code, but rather a head start for those assessing whether or not it's feasible to custom draw anything (result vs effort). In this sample project, I will highlight all even items of a ListBox with LightGray color.

VB.NET - When not to use Relaxed Delegate Conversion
· ☕ 2 min read
Relaxed delegate conversion enables you to assign subs and functions to delegates or handlers even when their signatures are not identical. In practice, it means that the following code [...] Can be written like this ... If you don't need to use event arguments, such as in the above scenario, your code becomes much more readable by omitting argument clause. For developers coming from C# background - yes, everything will work here, even with `Option Strict On`. Everything, but one thing...

VB.NET - The right way to read command line args
· ☕ 4 min read
While it may appear to be a simple question, there is really more to it. Please read this article carefully, especially if you have been writing command line utilities for 10+ years and never encountered any issues using standard .NET functionality.

VB.NET - Zip and Unzip String using GZipStream
· ☕ 2 min read
I tested this on HTML pages and it appears to be not the most efficient. In one of the examples, ~140K down to 44K. In comparison, Total Commander can zip down to 27K at the average compression level. But even with minimal compression the file remains at 32K.

VB.NET - Hidden items in a ListBox
· ☕ 1 min read
There is one good way to dynamically show/hide items in a ListBox - use a DataView as DataSource. You do not need to manually Add and Remove items from your list. In fact, coding effort is very low with this approach.

VB.NET - Delay form resize-to-fit until it loads
· ☕ 1 min read
Suppose every once in a while in your application you need to have a popup dialog being shown. This dialog is a value picker, nothing more. It shows as many values as your screen can handle. Problem happens when list population takes considerable amount of time, say, 5 seconds. Until then you are completely unsure which size it needs to resize to.

VB.NET - DropDownOpening Event For ComboBox
· ☕ 1 min read
Here is a proper way to do it - inherit a class from native ComboBox and override OnDropDown to raise a custom DropDownOpening event first. If you anticipate loading to take considerable time, you can wrap your reload code into a construct like this

VB.NET - Compare strings - case sensitivity issues
· ☕ 1 min read
I recently stumbled upon this problem in one of our company .NET projects. For some reason, project settings there were configured for Text comparison, rather than Binary. As a result, lower case strings were equal to upper case, which was discovered later when some bug in UI occured. There were three solutions available.