<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>vbnet on Neolisk's Tech Blog</title><link>/tags/vbnet/</link><description>Recent content in vbnet on Neolisk's Tech Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>neolisk@gmail.com (Victor Zakharov)</managingEditor><webMaster>neolisk@gmail.com (Victor Zakharov)</webMaster><copyright>©2020-2024 Victor Zakharov. All Rights Reserved</copyright><lastBuildDate>Fri, 14 Mar 2014 00:00:00 +0000</lastBuildDate><atom:link href="/tags/vbnet/index.xml" rel="self" type="application/rss+xml"/><item><title>VB.NET - Reading and writing app.config</title><link>/posts/2014-03-14-vbnet-reading-writing-app-config/</link><pubDate>Fri, 14 Mar 2014 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Sat, 05 Jun 2021 11:36:56 -0400</atom:modified><guid>/posts/2014-03-14-vbnet-reading-writing-app-config/</guid><description>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.
There are numerous examples and training articles on how to get started with writing your own classes for that.
Well guess what - you don&amp;rsquo;t need to write your own classes.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category></item><item><title>VB.NET - Getting Started with Custom Drawing</title><link>/posts/2013-04-13-vbnet-custom-drawing/</link><pubDate>Sat, 13 Apr 2013 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Thu, 30 Jan 2020 20:47:42 -0500</atom:modified><guid>/posts/2013-04-13-vbnet-custom-drawing/</guid><description>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&amp;rsquo;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. Here is an extract of how it&amp;rsquo;s done, if you don&amp;rsquo;t want to download anything.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 Private Shared Sub ListBox1_DrawItem(sender As System.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category></item><item><title>VB.NET - When not to use Relaxed Delegate Conversion</title><link>/posts/2013-02-14-vbnet-relaxed-delegate-conversion/</link><pubDate>Thu, 14 Feb 2013 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Thu, 30 Jan 2020 20:47:42 -0500</atom:modified><guid>/posts/2013-02-14-vbnet-relaxed-delegate-conversion/</guid><description>From MSDN:
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:
1 2 3 Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click MsgBox(&amp;#34;Hello&amp;#34;) End Sub Can be written like this:
1 2 3 Private Sub Button1_Click() Handles Button1.Click MsgBox(&amp;#34;Hello&amp;#34;) End Sub If you don&amp;rsquo;t need to use event arguments, such as in the above scenario, your code becomes much more readable by omitting argument clause.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category></item><item><title>VB.NET - The right way to read command line args</title><link>/posts/2013-02-08-vbnet-read-cmd-line-args/</link><pubDate>Fri, 08 Feb 2013 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Sat, 05 Jun 2021 11:36:56 -0400</atom:modified><guid>/posts/2013-02-08-vbnet-read-cmd-line-args/</guid><description>While it may appear to be a simple question, there is really more to it. Please read this article carefully, even if you believe you know how to handle this situation.
And especially if you have been writing command line utilities for 10+ years and never encountered any issues using standard .NET functionality.
Approaches you may be thinking about at the moment, which are often suggested at forums, unfortunately, do not work:</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category></item><item><title>VB.NET - Zip and Unzip String using GZipStream</title><link>/posts/2012-11-26-vbnet-zip-unzip-gzipstream/</link><pubDate>Mon, 26 Nov 2012 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Thu, 30 Jan 2020 20:47:42 -0500</atom:modified><guid>/posts/2012-11-26-vbnet-zip-unzip-gzipstream/</guid><description>Original code that I found is in C#. So I converted it to VB.NET and confirmed working:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 Imports System.IO &amp;#39;... Public Shared Function Zip(text As String) As String Dim buffer As Byte() = System.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category><category>zip</category></item><item><title>VB.NET - Hidden items in a ListBox</title><link>/posts/2012-06-21-vbnet-hidden-items-in-listbox/</link><pubDate>Thu, 21 Jun 2012 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Sat, 29 Feb 2020 15:06:15 -0500</atom:modified><guid>/posts/2012-06-21-vbnet-hidden-items-in-listbox/</guid><description>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.
Here is the extract in VB.NET, which shows the idea:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Public Class frm_main Dim _dataView As DataView Private Sub MyBase_Load(sender As System.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category><category>dotnet</category></item><item><title>VB.NET - Delay form resize-to-fit until it loads</title><link>/posts/2012-05-08-vbnet-delay-form-resize-to-fit/</link><pubDate>Tue, 08 May 2012 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Sat, 29 Feb 2020 15:14:35 -0500</atom:modified><guid>/posts/2012-05-08-vbnet-delay-form-resize-to-fit/</guid><description>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.
Attached is a piece of production quality code, with irrelevant features and optimizations left out.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category><category>dotnet</category></item><item><title>VB.NET - Get all controls of specified type from tree</title><link>/posts/2012-05-08-vbnet-get-all-controls-of-type/</link><pubDate>Tue, 08 May 2012 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Sat, 29 Feb 2020 15:18:14 -0500</atom:modified><guid>/posts/2012-05-08-vbnet-get-all-controls-of-type/</guid><description>Linearise ControlCollection tree into array of Control - generic extension method, no recursion, LINQ or GetNextControl:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 &amp;lt;System.Runtime.CompilerServices.Extension()&amp;gt; Friend Function GetAllControlsOfType(Of T As Control)(ByVal controls As Control.ControlCollection) As T() Dim controlsArray(controls.Count - 1) As Control controls.CopyTo(controlsArray, 0) Dim oldControlSieveList As New List(Of Control)(controlsArray) Dim newControlSieveList As List(Of Control) Dim targetControlList As New List(Of T) While oldControlSieveList.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category><category>dotnet</category></item><item><title>VB.NET - DropDownOpening Event For ComboBox</title><link>/posts/2012-02-21-vbnet-dropdownopening-event-combobox/</link><pubDate>Tue, 21 Feb 2012 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Sat, 29 Feb 2020 15:39:47 -0500</atom:modified><guid>/posts/2012-02-21-vbnet-dropdownopening-event-combobox/</guid><description>Here is a proper way to do it - inherit a class from native ComboBox and override OnDropDown to raise a custom DropDownOpening event first:
1 2 3 4 5 6 7 8 9 10 11 12 13 Public Class MyComboBox : Inherits ComboBox Public Event DropDownOpening(sender As Object, e As System.EventArgs) Protected Overrides Sub OnDropDown(e As System.EventArgs) RaiseEvent DropDownOpening(Me, e) MyBase.OnDropDown(e) End Sub End Class Private Sub MyComboBox1_DropDownOpening(sender As Object, e As System.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category><category>dotnet</category></item><item><title>VB.NET - Compare strings - case sensitivity issues</title><link>/posts/2011-04-21-vbnet-compare-strings-case-sensitivity/</link><pubDate>Thu, 21 Apr 2011 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Sun, 29 Mar 2020 19:47:31 -0400</atom:modified><guid>/posts/2011-04-21-vbnet-compare-strings-case-sensitivity/</guid><description>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:
Switch default comparison type on the project level. Go to Project / Properties / Option Compare -&amp;gt; Binary.</description><dc:creator>Victor Zakharov</dc:creator><category>dotnet</category><category>vbnet</category></item><item><title>VB.NET - Different Output in Designer VS Runtime</title><link>/posts/2010-07-18-vbnet-different-output-designer-vs-runtime/</link><pubDate>Sun, 18 Jul 2010 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Sat, 10 Oct 2020 16:43:45 -0400</atom:modified><guid>/posts/2010-07-18-vbnet-different-output-designer-vs-runtime/</guid><description>Let&amp;rsquo;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).
I went through different websites and forums looking for solution, with different opinions ranging from &amp;rsquo;not possible&amp;rsquo; to &amp;rsquo;need some special property attributes&amp;rsquo;.</description><dc:creator>Victor Zakharov</dc:creator><category>development</category><category>vbnet</category></item><item><title>VB.NET - Thread Safe Progress Bar</title><link>/posts/2010-03-28-vbnet-thread-safe-progress-bar/</link><pubDate>Sun, 28 Mar 2010 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Mon, 12 Oct 2020 10:35:19 -0400</atom:modified><guid>/posts/2010-03-28-vbnet-thread-safe-progress-bar/</guid><description>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, similar to the following:
I recently wrote a fairly simple wrapper class, which solves the problem. See code below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Public Class MyProgressBar : Inherits ProgressBar Public Delegate Sub SetRefreshCallback() Public Delegate Sub SetValueCallback(ByVal v As Integer) Public Shadows Text As String = String.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category><category>algorithm</category></item><item><title>VB.NET - Extract an Image Embedded as a Resource</title><link>/posts/2010-02-19-vbnet-extract-image-embedded-resource/</link><pubDate>Fri, 19 Feb 2010 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Mon, 12 Oct 2020 11:48:05 -0400</atom:modified><guid>/posts/2010-02-19-vbnet-extract-image-embedded-resource/</guid><description>Here&amp;rsquo;s one of the ways to embed an image into EXE file:
Left click the file in the project tree Set Build Action -&amp;gt; Embedded Resource. And how you can access this file in code:
1 2 3 4 5 6 Imports System.Reflection.Assembly &amp;#39;returns an embedded resource image by name Public Function EmbeddedImage(ByVal Name As String) As Bitmap Return New Bitmap(GetExecutingAssembly.GetManifestResourceStream(Name)) End Function It&amp;rsquo;s the shortest piece of code I found on the net.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category><category>development</category></item><item><title>VB.NET - Nullable DateTimePicker</title><link>/posts/2010-02-19-nullable-datetime-picker/</link><pubDate>Fri, 19 Feb 2010 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Mon, 12 Oct 2020 14:09:40 -0400</atom:modified><guid>/posts/2010-02-19-nullable-datetime-picker/</guid><description>One of the popular ways to do this - change format to &amp;quot; &amp;quot; (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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 Public Class MyDateTimePicker : Inherits DateTimePicker Private oldFormat As DateTimePickerFormat Private oldCustomFormat As String Private _value As Object Public Sub New() _value = MyBase.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category><category>development</category></item><item><title>VB.NET - Format DateTime With Milliseconds</title><link>/posts/2010-01-27-vbnet-format-datetime-with-ms/</link><pubDate>Wed, 27 Jan 2010 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Mon, 12 Oct 2020 15:00:46 -0400</atom:modified><guid>/posts/2010-01-27-vbnet-format-datetime-with-ms/</guid><description>Despite what people are saying on the net, you do not need to write your own method to include milliseconds when formatting a DateTime object. To achieve this, you can use the f modifier. For example, if you want to include thousands of a second (i.e. milliseconds), you can write something like this:
1 Now.ToString(“HH:mm:ss.fff”) You can set the fractional part to include up to 7 digits:
1 Now.ToString(“HH:mm:ss.fffffff”) If you try more, it will raise an exception.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category><category>development</category></item><item><title>VB.NET – Immediate Window – System Error &amp;H80040013&amp;</title><link>/posts/2010-01-27-vbnet-immediate-window-system-error/</link><pubDate>Wed, 27 Jan 2010 00:00:00 +0000</pubDate><author>neolisk@gmail.com (Victor Zakharov)</author><atom:modified>Mon, 12 Oct 2020 14:58:44 -0400</atom:modified><guid>/posts/2010-01-27-vbnet-immediate-window-system-error/</guid><description>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. Here is what I did:
Put the breakpoint somewhere in code.</description><dc:creator>Victor Zakharov</dc:creator><category>vbnet</category><category>development</category></item></channel></rss>