<?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>// do something here &#187; Visual Basic</title>
	<atom:link href="http://www.dosomethinghere.com/category/visual-basic/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dosomethinghere.com</link>
	<description>Turning impossibilities into 1s and 0s professionally since 0&#120;07C1</description>
	<lastBuildDate>Fri, 20 Jan 2012 20:07:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>OK, you may have had a tough coach at some point growing up, but you have to let it go&#8230;</title>
		<link>http://www.dosomethinghere.com/2011/02/17/ok-you-may-have-had-a-tough-coach-at-some-point-growing-up-but-you-have-to-let-it-go/</link>
		<comments>http://www.dosomethinghere.com/2011/02/17/ok-you-may-have-had-a-tough-coach-at-some-point-growing-up-but-you-have-to-let-it-go/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 18:37:54 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Inspirational code]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[Funny stuff]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=651</guid>
		<description><![CDATA[A co-worker found this nice little nugget in one of our sports web site applications: Dim isAssHeadCoach As Boolean = Session&#40;&#34;IsAssHeadCoach&#34;&#41; I hope it is meant to check for an assistant or associate head coach.]]></description>
			<content:encoded><![CDATA[<p>A co-worker found this nice little nugget in one of our sports web site applications:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> isAssHeadCoach <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Boolean</span> <span style="color: #008000;">=</span> Session<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;IsAssHeadCoach&quot;</span><span style="color: #000000;">&#41;</span></pre></div></div>

<p>I hope it is meant to check for an assistant or associate head coach.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2011/02/17/ok-you-may-have-had-a-tough-coach-at-some-point-growing-up-but-you-have-to-let-it-go/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t try, don&#8217;t catch</title>
		<link>http://www.dosomethinghere.com/2010/11/03/dont-try-dont-catch/</link>
		<comments>http://www.dosomethinghere.com/2010/11/03/dont-try-dont-catch/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 14:52:38 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[VS 2008]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=614</guid>
		<description><![CDATA[Have you ever had a situation where all of those nested try/catch blocks just get in your way when trying to chase down a problem? I just hate that. Luckily, in Visual Studio 2008 (and other versions, I am sure), there is a handy dandy way to disable all of the try/catch blocks when you [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever had a situation where all of those nested try/catch blocks just get in your way when trying to chase down a problem?  I just hate that.</p>
<p>Luckily, in Visual Studio 2008 (and other versions, I am sure), there is a handy dandy way to disable all of the try/catch blocks when you run the application in debug mode from the IDE.  Just go to the Debug menu, select Exceptions, click the box under the Thrown column for Common Language Runtime Exceptions (or others if that is what you are looking for), and click OK.  Now when the code has a problem, you see it right away instead of trying to work backwards through nested try/catch blocks in different classes and modules.</p>
<p>Just don&#8217;t forget to put it back to the way it was when you are done. I am not a huge fan of try/catch blocks, but their normal use definitely has its place.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2010/11/03/dont-try-dont-catch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is this string numeric?</title>
		<link>http://www.dosomethinghere.com/2010/10/27/is-this-string-numeric/</link>
		<comments>http://www.dosomethinghere.com/2010/10/27/is-this-string-numeric/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 17:47:50 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Inspirational code]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[What were they thinking?]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=606</guid>
		<description><![CDATA[This VB code was brought to my attention.  It is meant to look at a string variable (prefixText) and decide if the string is numeric or not, and return a data set (ds) by using a different method based on the result of the numeric test. (As always, this code is in a heavily used [...]]]></description>
			<content:encoded><![CDATA[<p>This VB code was brought to my attention.  It is meant to look at a string variable (prefixText) and decide if the string is numeric or not, and return a data set (ds) by using a different method based on the result of the numeric test.  (As always, this code is in a heavily used production environment.)</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #8D38C9; font-weight: bold;">If</span> Left(prefixText, 1) = <span style="color: #800000;">&quot;0&quot;</span> <span style="color: #8D38C9; font-weight: bold;">Or</span> Left(prefixText, 1) = <span style="color: #800000;">&quot;1&quot;</span> <span style="color: #8D38C9; font-weight: bold;">Or</span> Left(prefixText, 1) = <span style="color: #800000;">&quot;2&quot;</span> <span style="color: #8D38C9; font-weight: bold;">Or</span> Left(prefixText, 1) = <span style="color: #800000;">&quot;3&quot;</span> <span style="color: #8D38C9; font-weight: bold;">Or</span> Left(prefixText, 1) = <span style="color: #800000;">&quot;4&quot;</span> <span style="color: #8D38C9; font-weight: bold;">Or</span> Left(prefixText, 1) = <span style="color: #800000;">&quot;5&quot;</span> <span style="color: #8D38C9; font-weight: bold;">Or</span> Left(prefixText, 1) = <span style="color: #800000;">&quot;6&quot;</span> <span style="color: #8D38C9; font-weight: bold;">Or</span> Left(prefixText, 1) = <span style="color: #800000;">&quot;8&quot;</span> <span style="color: #8D38C9; font-weight: bold;">Or</span> Left(prefixText, 1) = <span style="color: #800000;">&quot;9&quot;</span> <span style="color: #8D38C9; font-weight: bold;">Then</span>
    ds = <span style="color: #E56717; font-weight: bold;">New</span> Users(_ConnStr).getUsersListByNumber(prefixText)
<span style="color: #8D38C9; font-weight: bold;">Else</span>
    ds = <span style="color: #E56717; font-weight: bold;">New</span> Users(_ConnStr).getUsersListByLastName(prefixText)
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span></pre></div></div>

<p>I have some great ideas on how to improve this code.  The first thing I would have done was to use OrElse instead of Or, it would speed things up tremendously.  And I would also have added in the test for the &#8220;7&#8243; character.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2010/10/27/is-this-string-numeric/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>2010 Central Ohio Day of .NET</title>
		<link>http://www.dosomethinghere.com/2010/06/05/2010-central-ohio-day-of-net/</link>
		<comments>http://www.dosomethinghere.com/2010/06/05/2010-central-ohio-day-of-net/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 23:48:56 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[CONDG]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=535</guid>
		<description><![CDATA[A co-w0rker and I attended the Central Ohio Day of .NET on June 5, 2010. There was quite a bit of good content at the conference, which is a real tribute to the organizers, volunteers, and presenters. The highlights of my day were sitting in on Matt Casto&#8217;s regular expressions talk, Phil Japikse&#8217;s M-V-VM primer, [...]]]></description>
			<content:encoded><![CDATA[<p>A co-w0rker and I attended the Central Ohio Day of .NET on June 5, 2010. There was quite a bit of good content at the conference, which is a real tribute to the organizers, volunteers, and presenters.</p>
<p>The highlights of my day were sitting in on Matt Casto&#8217;s regular expressions talk, Phil Japikse&#8217;s M-V-VM primer, discussing the etymology of the MongoDB project with Sam Corder (I still say it was named such after the character in Blazing Saddles), Michael Eaton&#8217;s talk on WPF, and Parag Joshi&#8217;s demonstration of XNA/Windows Phone 7 game development.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2010/06/05/2010-central-ohio-day-of-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VB.NET Printing For Dummies</title>
		<link>http://www.dosomethinghere.com/2010/03/16/vb-net-printing-for-dummies/</link>
		<comments>http://www.dosomethinghere.com/2010/03/16/vb-net-printing-for-dummies/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 01:02:18 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=485</guid>
		<description><![CDATA[In order to send stuff to the printer in VB.NET, it is not quite as simple as dealing with the Printer object as in VB6. There are a couple of extra steps involved. Here is what I found, along with some helper methods that you might find useful. On the form you want to print [...]]]></description>
			<content:encoded><![CDATA[<p>In order to send stuff to the printer in VB.NET, it is not quite as simple as dealing with the Printer object as in VB6. There are a couple of extra steps involved. Here is what I found, along with some helper methods that you might find useful.</p>
<p>On the form you want to print from, pull up the Toolbox and add a PrintDocument, a PrintDialog, and a Button, set the Document property of the PrintDialog to point to the PrintDocument you just created, and in the button&#8217;s Click event, insert the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;">    <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> butPrint_Click<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> System.<span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Handles</span> butPrint.<span style="color: #0000FF;">Click</span>
&nbsp;
        <span style="color: #0600FF;">If</span> PrintDialog1.<span style="color: #0000FF;">ShowDialog</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> Windows.<span style="color: #0000FF;">Forms</span>.<span style="color: #0000FF;">DialogResult</span>.<span style="color: #0600FF;">OK</span> <span style="color: #FF8000;">Then</span>
            PrintDocument1.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">Landscape</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
            PrintDocument1.<span style="color: #FF8000;">Print</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
    <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> PrintDocument1_PrintPage<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> System.<span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">Drawing</span>.<span style="color: #0000FF;">Printing</span>.<span style="color: #0000FF;">PrintPageEventArgs</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Handles</span> PrintDocument1.<span style="color: #0000FF;">PrintPage</span>
&nbsp;
        PrintTestPage<span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">Graphics</span>, PrintDocument1<span style="color: #000000;">&#41;</span>
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></div></div>

<p>The Print method call in the button click event then fires the PrintDocument PrintPage event. Notice that I have set the default page settings to landscape. Don&#8217;t forget to wire the PrintDialog Document property to your PrintDocument, otherwise if you change the printer to print to in the print dialog, the document will still go to the default printer.</p>
<p>The PrintTestPage method is just something simple that I put together to make sure that the coordinates and justifications are all working fine. Here is that code:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;">    <span style="color: #0600FF;">Sub</span> PrintTestPage<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> g <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">Drawing</span>.<span style="color: #0000FF;">Graphics</span>, <span style="color: #FF8000;">ByVal</span> doc <span style="color: #FF8000;">As</span> PrintDocument<span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> x, y <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span>
&nbsp;
        <span style="color: #FF8000;">For</span> x <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">To</span> <span style="color: #FF0000;">100</span> <span style="color: #FF8000;">Step</span> <span style="color: #FF0000;">10</span>
            <span style="color: #FF8000;">For</span> y <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">To</span> <span style="color: #FF0000;">100</span> <span style="color: #FF8000;">Step</span> <span style="color: #FF0000;">10</span>
                PrintAtLocationWithColor<span style="color: #000000;">&#40;</span>g, doc, x.<span style="color: #0000FF;">ToString</span> <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;, &quot;</span> <span style="color: #008000;">+</span> y.<span style="color: #0000FF;">ToString</span>, x, y, _
                                         <span style="color: #0600FF;">If</span><span style="color: #000000;">&#40;</span>x <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>, <span style="color: #808080;">&quot;L&quot;</span>, <span style="color: #0600FF;">If</span><span style="color: #000000;">&#40;</span>x <span style="color: #008000;">=</span> <span style="color: #FF0000;">100</span>, <span style="color: #808080;">&quot;R&quot;</span>, <span style="color: #808080;">&quot;C&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>, <span style="color: #0600FF;">If</span><span style="color: #000000;">&#40;</span>y <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>, <span style="color: #808080;">&quot;T&quot;</span>, <span style="color: #0600FF;">If</span><span style="color: #000000;">&#40;</span>y <span style="color: #008000;">=</span> <span style="color: #FF0000;">100</span>, <span style="color: #808080;">&quot;B&quot;</span>, <span style="color: #808080;">&quot;C&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>, _
                                         <span style="color: #808080;">&quot;Arial&quot;</span>, <span style="color: #FF0000;">8</span>, <span style="color: #0600FF;">True</span>, Brushes.<span style="color: #0600FF;">Red</span><span style="color: #000000;">&#41;</span>
            <span style="color: #FF8000;">Next</span>
        <span style="color: #FF8000;">Next</span>
&nbsp;
        PrintRectangle<span style="color: #000000;">&#40;</span>g, doc, <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">100</span>, <span style="color: #FF0000;">100</span><span style="color: #000000;">&#41;</span>
        PrintRectangle<span style="color: #000000;">&#40;</span>g, doc, <span style="color: #FF0000;">10</span>, <span style="color: #FF0000;">10</span>, <span style="color: #FF0000;">80</span>, <span style="color: #FF0000;">80</span><span style="color: #000000;">&#41;</span>
        PrintRectangle<span style="color: #000000;">&#40;</span>g, doc, <span style="color: #FF0000;">20</span>, <span style="color: #FF0000;">20</span>, <span style="color: #FF0000;">60</span>, <span style="color: #FF0000;">60</span><span style="color: #000000;">&#41;</span>
        PrintRectangle<span style="color: #000000;">&#40;</span>g, doc, <span style="color: #FF0000;">30</span>, <span style="color: #FF0000;">30</span>, <span style="color: #FF0000;">40</span>, <span style="color: #FF0000;">40</span><span style="color: #000000;">&#41;</span>
        PrintRectangle<span style="color: #000000;">&#40;</span>g, doc, <span style="color: #FF0000;">40</span>, <span style="color: #FF0000;">40</span>, <span style="color: #FF0000;">20</span>, <span style="color: #FF0000;">20</span><span style="color: #000000;">&#41;</span>
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></div></div>

<p>The two methods called here, PrintAtLocationWithColor and PrintRectangle, are shown here:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;">    <span style="color: #0600FF;">Sub</span> PrintAtLocationWithColor<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> pg <span style="color: #FF8000;">As</span> Graphics, <span style="color: #FF8000;">ByVal</span> pd <span style="color: #FF8000;">As</span> PrintDocument, <span style="color: #FF8000;">ByVal</span> s <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>, _
                                <span style="color: #FF8000;">ByVal</span> xPosition <span style="color: #FF8000;">As</span> Single, <span style="color: #FF8000;">ByVal</span> yPosition <span style="color: #FF8000;">As</span> Single, _
                                <span style="color: #FF8000;">ByVal</span> justification <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>, <span style="color: #FF8000;">ByVal</span> verticalJustification <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>, _
                                <span style="color: #FF8000;">ByVal</span> fontFace <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>, <span style="color: #FF8000;">ByVal</span> fontSize <span style="color: #FF8000;">As</span> Single, _
                                <span style="color: #FF8000;">ByVal</span> fontBold <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Boolean</span>, <span style="color: #FF8000;">ByVal</span> theColor <span style="color: #FF8000;">As</span> Brush<span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> w, h <span style="color: #FF8000;">As</span> Single
        <span style="color: #0600FF;">Dim</span> x, y <span style="color: #FF8000;">As</span> Single
        <span style="color: #0600FF;">Dim</span> f <span style="color: #FF8000;">As</span> Font
        <span style="color: #0600FF;">Dim</span> sty <span style="color: #FF8000;">As</span> FontStyle
&nbsp;
        sty <span style="color: #008000;">=</span> FontStyle.<span style="color: #0000FF;">Regular</span>
        <span style="color: #0600FF;">If</span> fontBold <span style="color: #FF8000;">Then</span> sty <span style="color: #008000;">=</span> sty <span style="color: #008000;">+</span> FontStyle.<span style="color: #0000FF;">Bold</span>
        <span style="color: #0600FF;">If</span> fontSize &lt; <span style="color: #FF0000;">1</span> <span style="color: #FF8000;">Then</span> fontSize <span style="color: #008000;">=</span> <span style="color: #FF0000;">8.0</span>
        f <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> Font<span style="color: #000000;">&#40;</span>fontFace, fontSize, sty<span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">If</span> pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">Landscape</span> <span style="color: #FF8000;">Then</span>
            x <span style="color: #008000;">=</span> xPosition <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0000FF;">Height</span><span style="color: #000000;">&#41;</span>
            y <span style="color: #008000;">=</span> yPosition <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0600FF;">Width</span><span style="color: #000000;">&#41;</span>
        <span style="color: #FF8000;">Else</span>
            x <span style="color: #008000;">=</span> xPosition <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0600FF;">Width</span><span style="color: #000000;">&#41;</span>
            y <span style="color: #008000;">=</span> yPosition <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0000FF;">Height</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
        w <span style="color: #008000;">=</span> pg.<span style="color: #0000FF;">MeasureString</span><span style="color: #000000;">&#40;</span>s, f<span style="color: #000000;">&#41;</span>.<span style="color: #0600FF;">Width</span>
        h <span style="color: #008000;">=</span> pg.<span style="color: #0000FF;">MeasureString</span><span style="color: #000000;">&#40;</span>s, f<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Height</span>
&nbsp;
        <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">UCase</span><span style="color: #000000;">&#40;</span>justification<span style="color: #000000;">&#41;</span>, <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;C&quot;</span> <span style="color: #FF8000;">Then</span>
            x <span style="color: #008000;">=</span> x <span style="color: #008000;">-</span> w <span style="color: #008000;">/</span> <span style="color: #FF0000;">2</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
        <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">UCase</span><span style="color: #000000;">&#40;</span>justification<span style="color: #000000;">&#41;</span>, <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;R&quot;</span> <span style="color: #FF8000;">Then</span>
            x <span style="color: #008000;">=</span> x <span style="color: #008000;">-</span> w
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
        <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">UCase</span><span style="color: #000000;">&#40;</span>verticalJustification<span style="color: #000000;">&#41;</span>, <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;C&quot;</span> <span style="color: #FF8000;">Then</span>
            y <span style="color: #008000;">=</span> y <span style="color: #008000;">-</span> h <span style="color: #008000;">/</span> <span style="color: #FF0000;">2</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
        <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">UCase</span><span style="color: #000000;">&#40;</span>verticalJustification<span style="color: #000000;">&#41;</span>, <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;B&quot;</span> <span style="color: #FF8000;">Then</span>
            y <span style="color: #008000;">=</span> y <span style="color: #008000;">-</span> h
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
        pg.<span style="color: #0000FF;">DrawString</span><span style="color: #000000;">&#40;</span>s, f, theColor, x, y<span style="color: #000000;">&#41;</span>
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
    <span style="color: #0600FF;">Sub</span> PrintRectangle<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> pg <span style="color: #FF8000;">As</span> Graphics, <span style="color: #FF8000;">ByVal</span> pd <span style="color: #FF8000;">As</span> PrintDocument, <span style="color: #FF8000;">ByVal</span> xPosition <span style="color: #FF8000;">As</span> Single, <span style="color: #FF8000;">ByVal</span> yPosition <span style="color: #FF8000;">As</span> Single, _
                                <span style="color: #FF8000;">ByVal</span> <span style="color: #0600FF;">width</span> <span style="color: #FF8000;">As</span> Single, <span style="color: #FF8000;">ByVal</span> height <span style="color: #FF8000;">As</span> Single<span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> w, h <span style="color: #FF8000;">As</span> Single
        <span style="color: #0600FF;">Dim</span> x, y <span style="color: #FF8000;">As</span> Single
&nbsp;
        <span style="color: #0600FF;">If</span> pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">Landscape</span> <span style="color: #FF8000;">Then</span>
            x <span style="color: #008000;">=</span> xPosition <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0000FF;">Height</span><span style="color: #000000;">&#41;</span>
            y <span style="color: #008000;">=</span> yPosition <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0600FF;">Width</span><span style="color: #000000;">&#41;</span>
            w <span style="color: #008000;">=</span> <span style="color: #0600FF;">width</span> <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0000FF;">Height</span><span style="color: #000000;">&#41;</span>
            h <span style="color: #008000;">=</span> height <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0600FF;">Width</span><span style="color: #000000;">&#41;</span>
        <span style="color: #FF8000;">Else</span>
            x <span style="color: #008000;">=</span> xPosition <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0600FF;">Width</span><span style="color: #000000;">&#41;</span>
            y <span style="color: #008000;">=</span> yPosition <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0000FF;">Height</span><span style="color: #000000;">&#41;</span>
            w <span style="color: #008000;">=</span> <span style="color: #0600FF;">width</span> <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0600FF;">Width</span><span style="color: #000000;">&#41;</span>
            h <span style="color: #008000;">=</span> height <span style="color: #008000;">/</span> <span style="color: #FF0000;">100</span> <span style="color: #008000;">*</span> <span style="color: #000000;">&#40;</span>pd.<span style="color: #0000FF;">DefaultPageSettings</span>.<span style="color: #0000FF;">PrintableArea</span>.<span style="color: #0000FF;">Height</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
        pg.<span style="color: #0000FF;">DrawRectangle</span><span style="color: #000000;">&#40;</span>Pens.<span style="color: #0600FF;">Black</span>, x, y, w, h<span style="color: #000000;">&#41;</span>
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></div></div>

<p>All of the positioning and size parameters of these methods are percentages across and down the page, which I find much easier to deal with than absolute or printer specific positioning. This makes it dead simple to scale the reports to any page size I want to use.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2010/03/16/vb-net-printing-for-dummies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET Kombat (Format vs. ToString)</title>
		<link>http://www.dosomethinghere.com/2010/02/23/net-kombat-format-vs-tostring/</link>
		<comments>http://www.dosomethinghere.com/2010/02/23/net-kombat-format-vs-tostring/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 03:43:51 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=468</guid>
		<description><![CDATA[In converting some legacy VB6 code to VB.NET, I noticed that there was a lot of use of the Format function in the code to convert numbers to strings. This makes sense as Format was pretty much the only game in town in VB6. However, in .NET, they introduced a handy-dandy .ToString() method that, on [...]]]></description>
			<content:encoded><![CDATA[<p>In converting some legacy VB6 code to VB.NET, I noticed that there was a lot of use of the Format function in the code to convert numbers to strings. This makes sense as Format was pretty much the only game in town in VB6.</p>
<p>However, in .NET, they introduced a handy-dandy .ToString() method that, on the surface, seems to do much the same thing as the Format function. I have been able to use them pretty much interchangeably with the desired results coming out every time.</p>
<p>I started to wonder which way was faster. Since I am a big proponent of empirical knowledge instead of just trying to get the theoretical story behind the two ways to do this, I rolled together this quick VB.NET console application:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">Imports System.Text
&nbsp;
Module Module1
&nbsp;
    <span style="color: #E56717; font-weight: bold;">Sub</span> Main()
&nbsp;
        <span style="color: #151B8D; font-weight: bold;">Dim</span> i <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Integer</span>
        <span style="color: #151B8D; font-weight: bold;">Dim</span> r <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #151B8D; font-weight: bold;">Random</span> = <span style="color: #E56717; font-weight: bold;">New</span> <span style="color: #151B8D; font-weight: bold;">Random</span>()
        <span style="color: #151B8D; font-weight: bold;">Dim</span> t <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Double</span>
&nbsp;
        System.Console.WriteLine(<span style="color: #800000;">&quot;10,000,000 Formats&quot;</span>)
        <span style="color: #151B8D; font-weight: bold;">Dim</span> sb1 <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #E56717; font-weight: bold;">New</span> stringbuilder
        t = Timer
        <span style="color: #8D38C9; font-weight: bold;">For</span> i = 1 <span style="color: #8D38C9; font-weight: bold;">To</span> 10000000
            sb1.Append(Format(r.NextDouble * 100.0, <span style="color: #800000;">&quot;###0.00 &quot;</span>))
        <span style="color: #8D38C9; font-weight: bold;">Next</span>
        System.Console.WriteLine(<span style="color: #800000;">&quot;Seconds elapsed: &quot;</span> + (Timer - t).ToString(<span style="color: #800000;">&quot;#######0.00&quot;</span>))
        System.Console.WriteLine(<span style="color: #800000;">&quot;Length of string builder: &quot;</span> + sb1.Length.ToString())
        System.Console.WriteLine()
&nbsp;
        System.Console.WriteLine(<span style="color: #800000;">&quot;10,000,000 ToStrings&quot;</span>)
        <span style="color: #151B8D; font-weight: bold;">Dim</span> sb2 <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #E56717; font-weight: bold;">New</span> StringBuilder
        t = Timer
        <span style="color: #8D38C9; font-weight: bold;">For</span> i = 1 <span style="color: #8D38C9; font-weight: bold;">To</span> 10000000
            sb2.Append((r.NextDouble * 100.0).ToString(<span style="color: #800000;">&quot;###0.00 &quot;</span>))
        <span style="color: #8D38C9; font-weight: bold;">Next</span>
        System.Console.WriteLine(<span style="color: #800000;">&quot;Seconds elapsed: &quot;</span> + (Timer - t).ToString(<span style="color: #800000;">&quot;#######0.00&quot;</span>))
        System.Console.WriteLine(<span style="color: #800000;">&quot;Length of string builder: &quot;</span> + sb2.Length.ToString())
        System.Console.WriteLine()
&nbsp;
        System.Console.WriteLine(<span style="color: #800000;">&quot;Press any key to end the program &quot;</span>)
        System.Console.ReadKey()
&nbsp;
    <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Sub</span>
&nbsp;
<span style="color: #8D38C9; font-weight: bold;">End</span> Module</pre></div></div>

<p>And here are the results:</p>
<p><a href="http://www.dosomethinghere.com/wp-content/uploads/2010/02/FormatVsToString.png"><img class="alignnone size-full wp-image-469" title="FormatVsToString" src="http://www.dosomethinghere.com/wp-content/uploads/2010/02/FormatVsToString.png" alt="" width="668" height="331" /></a></p>
<p>As you can see, the ToString method is about 15% faster when doing 10 million calls with random numbers.</p>
<p>Oh, and by the way, Happy <a href="http://www.ihoppancakeday.com/" target="_blank">Pancake Day</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2010/02/23/net-kombat-format-vs-tostring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy way to format the time difference between two dates</title>
		<link>http://www.dosomethinghere.com/2010/01/27/easy-way-to-format-the-time-difference-between-two-dates/</link>
		<comments>http://www.dosomethinghere.com/2010/01/27/easy-way-to-format-the-time-difference-between-two-dates/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 18:56:36 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[VB]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=457</guid>
		<description><![CDATA[In converting my VB6 code over to VB.NET, I was looking for an easy way to take the different between two DateTime items and display in hours and minutes.  The TimeSpan gives a nice structure to dive into the difference and see exactly the interval, but I was hoping to find a way to output [...]]]></description>
			<content:encoded><![CDATA[<p>In converting my VB6 code over to VB.NET, I was looking for an easy way to take the different between two DateTime items and display in hours and minutes.  The TimeSpan gives a nice structure to dive into the difference and see exactly the interval, but I was hoping to find a way to output this in the same way that you can use the ToShortTimeString method of DateTime.</p>
<p>As it turns out, I found a posting by Jay Barlow that mentions converting the time different to a date time, and then using a custom format string to do the work so that I wouldn&#8217;t have to.  Here is my new VB.NET code, where rec is a class that includes the start and end date and duration is a string that holds the information to be displayed:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #8D38C9; font-weight: bold;">If</span> rec.endDate IsNot <span style="color: #00C2FF; font-weight: bold;">Nothing</span> <span style="color: #8D38C9; font-weight: bold;">Then</span>
    <span style="color: #151B8D; font-weight: bold;">Dim</span> ts <span style="color: #151B8D; font-weight: bold;">As</span> TimeSpan = CDate(rec.endDate).Subtract(rec.startDate)
    <span style="color: #151B8D; font-weight: bold;">Dim</span> dt <span style="color: #151B8D; font-weight: bold;">As</span> DateTime = DateTime.MinValue.Add(ts)
    duration = <span style="color: #800000;">&quot;Event duration: &quot;</span> + dt.ToString(<span style="color: #800000;">&quot;H:mm&quot;</span>)
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span></pre></div></div>

<p>Oh, and one more thing.  Am I the only one in the world that thinks that iPad is the worst product name in history? Sure, it is so close to iPod so as to create brand recognition and draw comparisons, but I would just wonder what kind of names were shot down, and if any of them did not begin with the letter i.</p>
<p>By the way, Happy (Belated) Australia Day.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2010/01/27/easy-way-to-format-the-time-difference-between-two-dates/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>VB.NET radio button groups act differently than VB6 radio button groups</title>
		<link>http://www.dosomethinghere.com/2010/01/08/vb-net-radio-button-groups-act-differently-than-vb6-radio-button-groups/</link>
		<comments>http://www.dosomethinghere.com/2010/01/08/vb-net-radio-button-groups-act-differently-than-vb6-radio-button-groups/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 03:18:42 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[VB]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=452</guid>
		<description><![CDATA[The few dozen remaining WinForms developers left on this planet may have noticed that, for some reason, a group box with radio buttons in it as designed in the Visual Studio 2008 environment will have the first radio button of the first group box automatically selected when the form comes up, even though all of [...]]]></description>
			<content:encoded><![CDATA[<p>The few dozen remaining WinForms developers left on this planet may have noticed that, for some reason, a group box with radio buttons in it as designed in the Visual Studio 2008 environment will have the first radio button of the first group box automatically selected when the form comes up, even though all of the radio buttons have their Checked property set to false in the design environment.  It never used to do this in VB6, as when you ran the application, the group of radio buttons would have no members selected.</p>
<p>The problem manifests itself when you are trying to perform additional tasks in the CheckedChanged event of the radio buttons when the user selects one of the radio buttons, since the first radio button is being automatically selected.</p>
<p>I asked this question on Stack Overflow, and got a couple of replies. The one that I finally used to solve the problem was to set the Checked property of the radio buttons to false in the form&#8217;s Shown event, which I had never used before. By doing this, the first radio button was no longer automatically showing up checked.</p>
<p>One other thing that I had to do in addition was to cast the sender into a RadioButton and look at the Checked property of the clicked radio button in the CheckedChanged event, as that event is fired for radio buttons both being turned on and also turned off.</p>
<p>Oh, and happy National English Toffee Day!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2010/01/08/vb-net-radio-button-groups-act-differently-than-vb6-radio-button-groups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Control arrays in VB.NET</title>
		<link>http://www.dosomethinghere.com/2009/12/28/control-arrays-in-vb-net/</link>
		<comments>http://www.dosomethinghere.com/2009/12/28/control-arrays-in-vb-net/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 00:57:54 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=443</guid>
		<description><![CDATA[One of the things that I really liked (and used quite a bit) in the VB6 IDE was the ability to use the design surface to create a form with a bunch of controls with the same name as a control array. You would create the controls on the design page, give it the same [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that I really liked (and used quite a bit) in the VB6 IDE was the ability to use the design surface to create a form with a bunch of controls with the same name as a control array. You would create the controls on the design page, give it the same name as another control, and the Index property would automatically be incremented. This would then let me use a loop to manipulate and examine these controls.</p>
<p>This functionality is missing in VB.NET, as I discovered when I tried to do my first .NET Compact Framework application way back when Visual Studio 2003 was shiny and new, and has continued to be missing from the feature set in VS2005 and VS2008.</p>
<p>Microsoft is not much help on this front. Their solution is to create the forms in code, as described in this article:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa289500(VS.71).aspx" target="_blank">Not so helpful link</a></p>
<p>But I like using the design surface to create forms. A co-worker suggested we try to do a test in C# and tamper with the designer.cs file to create an array of controls in there, which worked OK. The big problems there were that the controls showed up on the design surface, but they could not be clicked and modified. Also, when we added a control to the form and saved it, all of the customizations we made to the designer file disappeared. (Oops.)</p>
<p>So instead, what I am now doing is creating my forms in the designer as before, with each control of the set having a different name with a number after it (such as cboName0, cboName1, etc.), referring to the index of the control in the array. At the top of the form&#8217;s class I have the arrays defined:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> cboName<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">10</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">as</span> ComboBox
<span style="color: #0600FF;">Dim</span> lblNumber<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">10</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">as</span> Label</pre></div></div>

<p>Then, in the form load event, I am calling this subroutine:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Sub</span> SetUpControlArrays<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
    <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> cb In <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Controls</span>.<span style="color: #0000FF;">OfType</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Of</span> ComboBox<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">If</span> cb.<span style="color: #0000FF;">Name</span>.<span style="color: #0000FF;">Contains</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;cboName&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            cboName<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">CInt</span><span style="color: #000000;">&#40;</span>cb.<span style="color: #0000FF;">Name</span>.<span style="color: #0600FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;cboName&quot;</span>, <span style="color: #808080;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> cb
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
    <span style="color: #FF8000;">Next</span>
&nbsp;
    <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> lbl In <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Controls</span>.<span style="color: #0000FF;">OfType</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Of</span> Label<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">If</span> lbl.<span style="color: #0000FF;">Name</span>.<span style="color: #0000FF;">Contains</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;lblNumber&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            lblNumber<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">CInt</span><span style="color: #000000;">&#40;</span>lbl.<span style="color: #0000FF;">Name</span>.<span style="color: #0600FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;lblNumber&quot;</span>, <span style="color: #808080;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> lbl
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
    <span style="color: #FF8000;">Next</span>
&nbsp;
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></div></div>

<p>Now I have the ability to address the controls in the same way that I used to do in VB6. The fact that I lived with this missing feature for about 6 years and just now figuring out a decent way around the problem pretty much guarantees that VS2010 will put the control arrays back in.</p>
<p><strong>EDIT:</strong> At the request of a Strong Bad fan who shall remain nameless, I changed up the code above to be a bit more friendly. The previous code only extracted the rightmost 1 character from the name of the control on the design surface, which would not work if you had a control name such as cboName10.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2009/12/28/control-arrays-in-vb-net/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to get the version number of a running process</title>
		<link>http://www.dosomethinghere.com/2009/11/24/how-to-get-the-version-number-of-a-running-process/</link>
		<comments>http://www.dosomethinghere.com/2009/11/24/how-to-get-the-version-number-of-a-running-process/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 01:37:47 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=396</guid>
		<description><![CDATA[I wanted to have my .NET based Palm OS conduit DLL be able to report the version of the HotSync Manager that the user has installed on their computer. Initially, I was going to try to read the version of the executable, but then I would first have to find the path to the executable, [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to have my .NET based Palm OS conduit DLL be able to report the version of the HotSync Manager that the user has installed on their computer. Initially, I was going to try to read the version of the executable, but then I would first have to find the path to the executable, and hope that this would be a reliable enough method.</p>
<p>As it turns out, after I did a little investigation, I found out that it is not necessary to try and figure out where the HotSync Manager is installed by reading the appropriate registry key to get the HotSync Manager location and then trying to get the version number of the assembly at that path. Because the user is in the conduit code, the HotSync Manager (HOTSYNC.EXE) is already in the running processes list. It just so happens that in the System.Diagnostics namespace there is a handy dandy method that gets all of the running processes, along with a goodly amount of information about each process, including the version number.</p>
<p>So here is my VB.NET code that searches for the HotSync Manager process and returns the version number as a string.</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Function</span> GetHotSyncVersion<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
&nbsp;
    <span style="color: #0600FF;">Dim</span> versionString <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Unknown&quot;</span>
&nbsp;
    <span style="color: #0600FF;">Dim</span> procList <span style="color: #FF8000;">As</span> List<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Of</span> Process<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> Process.<span style="color: #0000FF;">GetProcesses</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">ToList</span>
    <span style="color: #0600FF;">Dim</span> hotSyncProcess <span style="color: #FF8000;">As</span> Process <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
    <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> p In procList
        <span style="color: #0600FF;">If</span> p.<span style="color: #0000FF;">ProcessName</span>.<span style="color: #0000FF;">ToUpper</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;HOTSYNC&quot;</span> <span style="color: #FF8000;">Then</span>
            hotSyncProcess <span style="color: #008000;">=</span> p
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
    <span style="color: #FF8000;">Next</span>
&nbsp;
    <span style="color: #0600FF;">If</span> hotSyncProcess <span style="color: #FF8000;">IsNot</span> <span style="color: #FF8000;">Nothing</span> <span style="color: #FF8000;">Then</span>
        versionString <span style="color: #008000;">=</span> hotSyncProcess.<span style="color: #0000FF;">MainModule</span>.<span style="color: #0000FF;">FileVersionInfo</span>.<span style="color: #0000FF;">FileVersion</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
    <span style="color: #FF8000;">Return</span> versionString
&nbsp;
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></pre></div></div>

<p>Sorry I missed the CIDUG meeting tonight.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2009/11/24/how-to-get-the-version-number-of-a-running-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

