#vbnet
16 posts tagged vbnet.
2014 1 post
Updated
VB.NET - Reading and writing app.config
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.
2013 3 posts
Updated
VB.NET - Getting Started with Custom Drawing
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.
Updated
VB.NET - When not to use Relaxed Delegate Conversion
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...
Updated
VB.NET - The right way to read command line args
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.
2012 5 posts
Updated
VB.NET - Zip and Unzip String using GZipStream
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.
Updated
VB.NET - Hidden items in a ListBox
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.
Updated
VB.NET - Delay form resize-to-fit until it loads
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.
Updated
VB.NET - Get all controls of specified type from tree
Linearise ControlCollection tree into array of Control - generic extension method, no recursion, LINQ or GetNextControl. See attached project for usage/sample (VB.NET 4.0, Visual Studio 2010).
Updated
VB.NET - DropDownOpening Event For ComboBox
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
2011 1 post
Updated
VB.NET - Compare strings - case sensitivity issues
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.
2010 6 posts
Updated
VB.NET - Different Output in Designer VS Runtime
Let's say you want your custom control display empty string in a certain field, if it has a default value. For example, if your Text field on a custom Label control is identical to its name, show Text field as blank. Would be nice if it worked both ways, i.e. leaving Text field blank would make it identical to the name (or following a certain pattern).
Updated
VB.NET - Thread Safe Progress Bar
Normally, when you are using .NET built-in progress bar in a multi-threaded application without Callback tricks, you are likely to get an exception on value assign. I recently wrote a fairly simple wrapper class, which solves the problem.
Updated
VB.NET - Extract an Image Embedded as a Resource
Here's one of the ways to embed an image into EXE file Left click the file in the project tree Set [Build Action] -> [Embedded Resource]. And here's how you can access this file in code...
Updated
VB.NET - Nullable DateTimePicker
One of the popular ways to do this - change format to " " (space) whenever null value is being set and roll it back to the old format on anything else. I have been looking for clean implementation of this approach. In the end I decided to write my own, using source code available on the net. Here is what I came up with.
Updated
VB.NET - Format DateTime With Milliseconds
Despite what people are saying on the net, you do not need to write your own method to include milliseconds when formatting DateTime object. To achieve this, you can use “f”. For example, if you want to include thousands of a second (i.e. milliseconds), you can write something like this [...]
Updated
VB.NET – Immediate Window – System Error &H80040013&
This appears to be a known bug in Visual Studio. I encountered it when my VS 2008 SP1 was idle for a considerable amount of time, hanging minimized in the task bar. Standard close/reopen VS did not help. There were no strange processes in Task Manager either. After some failed commands (same error), I found a workaround for this issue.