<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ScarTech &#187; VB.NET</title>
	<atom:link href="http://www.scartech.net/category/vbnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scartech.net</link>
	<description>The musings of a confessed code junkie and a game geek.</description>
	<lastBuildDate>Wed, 07 Jul 2010 01:34:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Auto Format Code in Visual Studio 2008</title>
		<link>http://www.scartech.net/2009/01/27/auto-format-code-in-visual-studio-2008/</link>
		<comments>http://www.scartech.net/2009/01/27/auto-format-code-in-visual-studio-2008/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 00:53:19 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.scartech.net/?p=389</guid>
		<description><![CDATA[My new favorite macro in Visual Studio 2008 is control-D then control-K. Hit that key sequence and voila: all code on the page has been formatted. It&#8217;s especially helpful when copy-pasting. Just a tip from Tim to make your life easier!]]></description>
			<content:encoded><![CDATA[<p>My new favorite macro in <a href="http://www.microsoft.com/visualstudio/en-us/default.mspx">Visual Studio 2008</a> is control-D then control-K. Hit that key sequence and voila: all code on the page has been formatted. It&#8217;s especially helpful when copy-pasting. Just a tip from Tim to make your life easier! <img src='http://www.scartech.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.scartech.net/2009/01/27/auto-format-code-in-visual-studio-2008/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Is it null, or is it empty?</title>
		<link>http://www.scartech.net/2008/06/03/is-it-null-or-is-it-empty/</link>
		<comments>http://www.scartech.net/2008/06/03/is-it-null-or-is-it-empty/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 01:27:58 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.scartech.net/2008/06/03/is-it-null-or-is-it-empty/</guid>
		<description><![CDATA[The IsNullOrEmpty method was added to the String class in the 2.0 Framework, and it makes testing for an empty or null string as easy as a single function call. Instead of having to test the String object if it&#8217;s null then checking if it&#8217;s empty, this can now be done in one easy method [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx">IsNullOrEmpty</a> method was added to the <a href="http://msdn.microsoft.com/en-us/library/system.string.aspx">String</a> class in the 2.0 Framework, and it makes testing for an empty or null string as easy as a single function call. Instead of having to test the String object if it&#8217;s null then checking if it&#8217;s empty, this can now be done in one easy method call.<br />
VB.NET</p>
<blockquote>
<pre><span style="color: Blue">Dim</span> s <span style="color: Blue">As</span> <span style="color: Blue">String</span>

<span style="color: Blue">If</span> <span style="color: Blue">String</span>.IsNullOrEmpty(s) <span style="color: Blue">Then</span>
  Console.WriteLine(<span style="color: Maroon">"String is null or empty."</span>)
<span style="color: Blue">Else</span>
  Console.WriteLine(<span style="color: Blue">String</span>.Format(<span style="color: Maroon">"String = {0}"</span>, s))
<span style="color: Blue">EndIf</span></pre>
</blockquote>
<p>This isn&#8217;t exactly an earth shattering discovery, but it&#8217;s useful nonetheless.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scartech.net/2008/06/03/is-it-null-or-is-it-empty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Who watches the watcher?</title>
		<link>http://www.scartech.net/2008/03/13/who-watches-the-watcher/</link>
		<comments>http://www.scartech.net/2008/03/13/who-watches-the-watcher/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 18:06:44 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.scartech.net/2008/03/13/who-watches-the-watcher/</guid>
		<description><![CDATA[I recently completed a project at work that included the requirement to monitor data files on 30 or more different Windows NT4 machines for changes. Naturally I thought of using the FileSystemWatcher class in the System.IO namespace. As anyone who has used the FileSystemWatcher has come to realize, it can be unreliable. Specifically, if one [...]]]></description>
			<content:encoded><![CDATA[<p>I recently completed a project at work that included the requirement to monitor data files on 30 or more different Windows NT4 machines for changes. Naturally I thought of using the FileSystemWatcher class in the System.IO namespace. As anyone who has used the FileSystemWatcher has come to realize, it can be unreliable. Specifically, if one of the NT4 machines were rebooted, the watcher would &#8220;lose&#8221; its ability to capture the file modification events I needed. What was my solution? Well, it&#8217;s a bit of a hack. Actually, it&#8217;s a really big hack. I used the Timer class in the System.Threading namespace to restart the watchers at a specified interval and to check for changes to the files that I might have missed. The files don&#8217;t change very often, so the solution has worked so far. I also can&#8217;t install anything on the NT4 machines, so this is what I was forced to do. Come on. I&#8217;m not the only one to hack something together like this. Am I?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scartech.net/2008/03/13/who-watches-the-watcher/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Case for Generics in VB.NET &#8211; Part 2</title>
		<link>http://www.scartech.net/2007/11/12/a-case-for-generics-in-vbnet-part-2/</link>
		<comments>http://www.scartech.net/2007/11/12/a-case-for-generics-in-vbnet-part-2/#comments</comments>
		<pubDate>Tue, 13 Nov 2007 00:57:36 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Generics]]></category>

		<guid isPermaLink="false">http://www.scartech.net/archives/52</guid>
		<description><![CDATA[In the first part of my series on Generics in VB.NET I discussed the advantages of generic collections. In this installment I&#8217;ll cover the Nullable Generic Structure. First, let&#8217;s cover some background. A type is nullable if it can be assigned a value or Nothing (null in C#). For example a String object is nullable [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://www.scartech.net/archives/27">first part</a> of my series on Generics in VB.NET I discussed the advantages of generic collections. In this installment I&#8217;ll cover the <a href="http://msdn2.microsoft.com/en-us/library/b3h38hb0.aspx">Nullable Generic Structure</a>.</p>
<p>First, let&#8217;s cover some background. A type is nullable if it can be assigned a value or Nothing (null in C#). For example a String object is nullable because it can be assigned either a value or Nothing. On the other hand, value types are not nullable. An Integer cannot be assigned Nothing. To put it simply, reference types are nullable. Value types are not.</p>
<p>Now that we&#8217;re experts at nullable and value types in .NET, let&#8217;s cover the usefulness of the nullable generic structure. At times it&#8217;s useful to know if a value has been assigned to a variable that you cannot initialize as Nothing, but you don&#8217;t want to initialize it with the default value. Using the nullable structure can help simplify your code in certain instances. Let&#8217;s take a look at two examples.</p>
<p><strong>Without using the nullable structure</strong>:</p>
<blockquote><p>Dim value1 As Integer</p>
<p>&#8216;do some work<br />
&#8230;</p>
<p>If value1 = 0 Then<br />
      &#8216;the value wasn&#8217;t changed, but we can&#8217;t be completely sure it wasn&#8217;t actually set to 0<br />
      &#8216;because an Integer is initialized to 0<br />
Else<br />
      &#8216;we&#8217;re sure the value was changed, so we&#8217;ll continue processing<br />
End If</p></blockquote>
<p><strong>Now using the nullable structure</strong>:</p>
<blockquote><p>Dim value1 As Nullable(Of Integer)</p>
<p>&#8216;do some work<br />
&#8230;</p>
<p>If Not value1.HasValue Then<br />
     &#8216;because the variable doesn&#8217;t have a value,<br />
     &#8216;we&#8217;re sure the value hasn&#8217;t been set<br />
Else<br />
     &#8216;we&#8217;re sure the value was changed, so we&#8217;ll continue processing<br />
End If</p></blockquote>
<p>Now of course these examples are contrived, but I think they prove the point. If you want to check if a value type has been assigned a value, consider using the nullable generic structure. It will give you an easy way to &#8220;assign&#8221; and test for null in a value type.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scartech.net/2007/11/12/a-case-for-generics-in-vbnet-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Case For Generics In VB.NET &#8211; Part 1</title>
		<link>http://www.scartech.net/2007/10/27/a-case-for-generics-in-vbnet/</link>
		<comments>http://www.scartech.net/2007/10/27/a-case-for-generics-in-vbnet/#comments</comments>
		<pubDate>Sun, 28 Oct 2007 01:53:57 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Generics]]></category>

		<guid isPermaLink="false">http://www.scartech.net/archives/27</guid>
		<description><![CDATA[Dim, ReDim, ReDim Preseve, Repeat. Sound familiar? If so, maybe you want to look into generic collections. In the System.Collections namespace the ArrayList class will give you a dynamically allocated list of objects that&#8217;s easy to use. You won&#8217;t need to worry about ReDim&#8217;ing the array if you need to add items, and you won&#8217;t have [...]]]></description>
			<content:encoded><![CDATA[<p>Dim, ReDim, ReDim Preseve, Repeat. Sound familiar? If so, maybe you want to look into generic collections. In the <a href="http://msdn2.microsoft.com/en-us/library/system.collections.aspx">System.Collections</a> namespace the <a href="http://msdn2.microsoft.com/en-us/library/system.collections.arraylist.aspx">ArrayList </a>class will give you a dynamically allocated list of objects that&#8217;s easy to use. You won&#8217;t need to worry about ReDim&#8217;ing the array if you need to add items, and you won&#8217;t have to deal with array indexing issues when adding/removing items.</p>
<p>Example using an array.</p>
<blockquote><p>&#8216;create the string array with an initial size<br />
Dim values As String(1)</p>
<p>&#8216;add a value<br />
values(0) = &#8220;test 1&#8243;</p>
<p>&#8216;&#8230;. do some work &#8230;.</p>
<p>&#8216;now we need to add another value to the array,<br />
&#8216;so we need to do a ReDim<br />
ReDim Preserve values(2)<br />
values(1) = &#8220;test 2&#8243;</p></blockquote>
<p>Now let&#8217;s rewrite the example using an ArrayList</p>
<blockquote><p>&#8216;create the arraylist<br />
Dim values As New ArrayList()</p>
<p>&#8216;add a value<br />
values.Add(&#8220;test 1&#8243;)</p>
<p>&#8216;&#8230;. do some work &#8230;.</p>
<p>&#8216;now add another value, but there&#8217;s no need to ReDim<br />
values.Add(&#8220;test 2&#8243;)</p></blockquote>
<p>For me, there&#8217;s one drawback to ArrayList. <a href="http://en.wikipedia.org/wiki/Type_safety">Type safety</a>. If you want compile time checking of the object types you&#8217;re adding to a collection, look at the generic <a href="http://msdn2.microsoft.com/en-us/library/6sh2ey19.aspx">List(Of Object)</a> class in the <a href="http://msdn2.microsoft.com/en-us/library/system.collections.generic.aspx">System.Collections.Generic</a> namespace. You&#8217;ll get type safety and a performance boost by using the generic List object, not to mention Intellisense support.</p>
<blockquote><p>&#8216;create the list<br />
Dim values As New List(Of String)<br />
values.Add(&#8220;test 1&#8243;)</p></blockquote>
<p>You aren&#8217;t limited to a simple list either. There&#8217;s a <a href="http://msdn2.microsoft.com/en-us/library/system.collections.sortedlist.aspx">sorted list</a>, a <a href="http://msdn2.microsoft.com/en-us/library/xfhwa508.aspx">dictionary</a>, and a <a href="http://msdn2.microsoft.com/en-us/library/f7fta44c.aspx">sorted dictionary</a>. For me, the choice is easy. I use generic collections where I might have used an array before. That&#8217;s not saying I never use a simple array any more, but generic collections are definitely a good addition to my toolkit.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scartech.net/2007/10/27/a-case-for-generics-in-vbnet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
