<?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>Occam&#039;s Razor &#187; vb.net</title>
	<atom:link href="http://developmentgeek.com/blog/tag/vbnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://developmentgeek.com/blog</link>
	<description>Fueled by Mt. Dew and a love for technology</description>
	<lastBuildDate>Tue, 13 Jul 2010 15:39:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=5474</generator>
		<item>
		<title>Getting To Know Eu&#8230;ler</title>
		<link>http://developmentgeek.com/blog/20100226/getting-to-know-eu-ler/</link>
		<comments>http://developmentgeek.com/blog/20100226/getting-to-know-eu-ler/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 00:58:04 +0000</pubDate>
		<dc:creator>Kevin Fairchild</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[challenge]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projecteuler]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://developmentgeek.com/blog/?p=88</guid>
		<description><![CDATA[One of the best ways to get to know a programmer is to see their code. You might not know their favorite hobbies, favorite foods, or favorite football team (trick question, programmers don&#8217;t like football. Hehe), but getting a glimpse at how someone goes about solving problems can really be quite helpful. With that in [...]]]></description>
			<content:encoded><![CDATA[<p>One of the best ways to get to know a programmer is to see their code.  You might not know their favorite hobbies, favorite foods, or favorite football team (trick question, programmers don&#8217;t like football. Hehe), but getting a glimpse at how someone goes about solving problems can really be quite helpful.</p>
<p>With that in mind, I&#8217;m going to be taking part in <a href="http://ProjectEuler.net">ProjectEuler.net</a>.  It&#8217;s all math-based to one degree or another.  I am horrible at math, really.  I know enough to get by, but a lot of it I&#8217;ve forgotten since being out of school.  But, I must admit, I love a figuring out puzzles &#8212; especially by programming &#8212; so I&#8217;m anxious to get started.</p>
<p>If you&#8217;d like to follow along, feel free to set up an account on their site and try the stuff out yourself.  It can get quite addictive <img src='http://developmentgeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Since I&#8217;m going to post code-samples here, I might as well include one of my &#8220;helper&#8221; routines I ended up using in a couple of solutions.  Since a few of the problems involved prime numbers, I made a generic function for allowing me to determine whether a specific number is a prime or not.</p>
<p>I&#8217;m sure there are more effective ways of figuring out if a number is a prime, but math was never a subject a particularly excelled at&#8230;</p>
<p><code>Function IsPrime(ByVal tmpVal As Long) As Boolean<br />
        Dim strVal As String = tmpVal.ToString</p>
<p>        'If the number ends in 0,2,4,5,6,8 then it's NOT prime (might be a composite)<br />
        If strVal.Length > 1 AndAlso strVal.Substring(strVal.Length - 1, 1) = "0" Then Return False<br />
        If strVal.Length > 1 AndAlso strVal.Substring(strVal.Length - 1, 1) = "2" Then Return False<br />
        If strVal.Length > 1 AndAlso strVal.Substring(strVal.Length - 1, 1) = "4" Then Return False<br />
        If strVal.Length > 1 AndAlso strVal.Substring(strVal.Length - 1, 1) = "5" Then Return False<br />
        If strVal.Length > 1 AndAlso strVal.Substring(strVal.Length - 1, 1) = "6" Then Return False<br />
        If strVal.Length > 1 AndAlso strVal.Substring(strVal.Length - 1, 1) = "8" Then Return False</p>
<p>        'Except for the number 2, if a number is even, it's always composite<br />
        If tmpVal <> 2 AndAlso tmpVal Mod 2 = 0 Then Return False</p>
<p>        'If a number's digits add up to a number which is divisible by 3, it's composite<br />
        Dim tmpDigitSum As Integer = 0<br />
        If strVal.Length > 1 Then<br />
            For k As Integer = 0 To strVal.Length - 1<br />
                tmpDigitSum += strVal.Substring(k, 1)<br />
            Next<br />
            If tmpDigitSum = 3 Then Return False<br />
        End If</p>
<p>        'If a number's square root is an integer, it's a composite<br />
        If System.Math.Sqrt(tmpVal) = CInt(System.Math.Sqrt(tmpVal)) Then Return False</p>
<p>        'If it's not divisible by itself, it's not Prime<br />
        If tmpVal Mod tmpVal <> 0 Then Return False</p>
<p>        Dim MaxVal As Long = System.Math.Sqrt(tmpVal)</p>
<p>        For k As Long = 2 To MaxVal<br />
            If tmpVal Mod k = 0 AndAlso k <> 1 Then<br />
                Return False<br />
            End If<br />
        Next</p>
<p>        Return True<br />
End Function</code></p>
]]></content:encoded>
			<wfw:commentRss>http://developmentgeek.com/blog/20100226/getting-to-know-eu-ler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Close Enough</title>
		<link>http://developmentgeek.com/blog/20080426/close-enough/</link>
		<comments>http://developmentgeek.com/blog/20080426/close-enough/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 21:28:08 +0000</pubDate>
		<dc:creator>Kevin Fairchild</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://developmentgeek.com/blog/?p=69</guid>
		<description><![CDATA[I was able to finally get the table structure the way I wanted it. Since my source data is all plain text, I identify the URLs and then add in the HREF data with the url as the link text as well as the location. Add in basic tags for displaying the images I want [...]]]></description>
			<content:encoded><![CDATA[<p>I was able to finally get the table structure the way I wanted it.</p>
<p>Since my source data is all plain text, I identify the URLs and then add in the HREF data with the url as the link text as well as the location. Add in basic tags for displaying the images I want next to the next and &#8212; BAM! &#8212; now I have a grid showing the posts/pictures for each user.</p>
<p>Once that was in place, I did something similar for usernames.</p>
<p>Last but not least, I hijacked the DocumentCompleted event of the browser control to add an OnClick event for each link&#8230;  That event lets me selectively perform actions based on what I need&#8230; So clicking on a normal URL will open up a new browser window displaying what&#8217;s needed. Clicking on the image link (the user pic) performs some stuff on the client side to allow replying to that person&#8217;s post.</p>
<p>It&#8217;ll make a bit more sense once I post some pics&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://developmentgeek.com/blog/20080426/close-enough/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More than one way to skin a cat&#8230;</title>
		<link>http://developmentgeek.com/blog/20080426/more-than-one-way-to-skin-a-cat/</link>
		<comments>http://developmentgeek.com/blog/20080426/more-than-one-way-to-skin-a-cat/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 08:59:16 +0000</pubDate>
		<dc:creator>Kevin Fairchild</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://developmentgeek.com/blog/?p=68</guid>
		<description><![CDATA[Needed to display some data in a grid. No biggie. But I wanted some custom formatting &#8212; mainly allowing for links and whatnot. Eventually, I was left with two options &#8212; inheriting a richtextbox control and using that as a custom datagridcolumn or doing an override on a paint event for the cell&#8230; Started with [...]]]></description>
			<content:encoded><![CDATA[<p>Needed to display some data in a grid.  No biggie.  But I wanted some custom formatting &#8212; mainly allowing for links and whatnot.  Eventually, I was left with two options &#8212; inheriting a richtextbox control and using that as a custom datagridcolumn or doing an override on a paint event for the cell&#8230;</p>
<p>Started with the richtextbox method, but it seemed like the only way that worked was if the editing control was overridden&#8230; Not much use for displaying the stuff.  Meh.</p>
<p>So I tried out using the paint event.  That actually worked pretty good at first.  Using GDI+ DrawString calls to write what I wanted in the color/formatting I wanted &#8212; albeit in a somewhat clumsy way.  But then I began running into issues when I had multiple strings needing formatting or if the string needed to wrap within the cell.</p>
<p>Deciding both method were way too complex for what I needed, I started rethinking the issue.  What I <em>really</em> needed was a way to have it render HTML text.  That way I could do some handy-wavy string manipulations to set the various tags I needed and that would be all that&#8217;s needed.</p>
<p>After looking around for a while for a simple way of doing that within the datagridview, I changed my design plan a bit&#8230;</p>
<p>That&#8217;s when I got an idea&#8230;</p>
<p>If I used a web browser control, I&#8217;d certainly have the HTML support I needed.  And by using tables within HTML, I&#8217;d be able to get pretty close to the same grid feel as that original datagridview.</p>
]]></content:encoded>
			<wfw:commentRss>http://developmentgeek.com/blog/20080426/more-than-one-way-to-skin-a-cat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
