<?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>Armswiper.co.uk &#187; MSDN</title>
	<atom:link href="http://www.armswiper.co.uk/blog/view/tag/msdn/feed" rel="self" type="application/rss+xml" />
	<link>http://www.armswiper.co.uk</link>
	<description>Developer, Rower, Funny Man</description>
	<lastBuildDate>Thu, 07 Apr 2011 19:18:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>VBScript function IsNumeric</title>
		<link>http://www.armswiper.co.uk/blog/view/548</link>
		<comments>http://www.armswiper.co.uk/blog/view/548#comments</comments>
		<pubDate>Tue, 18 Aug 2009 09:29:44 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[IsNumeric]]></category>
		<category><![CDATA[MSDN]]></category>
		<category><![CDATA[Stupid]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.armswiper.co.uk/?p=548</guid>
		<description><![CDATA[Brilliant. Last night, we discovered that the VBScript function &#8220;IsNumeric&#8221; is a little more clever than you&#8217;d like, but there&#8217;s also no simpler version either. Consider the following scenario. We have the user input in a bit of text on screen. We need to process that (client-side), and part of that processing needs to find [...]]]></description>
			<content:encoded><![CDATA[<p>Brilliant.</p>
<p>Last night, we discovered that the VBScript function &#8220;IsNumeric&#8221; is a little more clever than you&#8217;d like, but there&#8217;s also no simpler version either.</p>
<p>Consider the following scenario.</p>
<p>We have the user input in a bit of text on screen. We need to process that (client-side), and part of that processing needs to find out if it is a number or not (i.e. if it&#8217;s a number, do this, otherwise, do that.)</p>
<p>Last night, we encountered a problem with the word &#8220;65d1&#8243; &#8211; clearly, it&#8217;s not a number (the &#8220;d&#8221; gives that away,) however, IsNumeric says that it is. If you CInt(&#8220;65d1&#8243;) you get 650. WTF?</p>
<p>A little more testing reveals the following:</p>
<pre>CInt("65d0")  =&gt; 65
CInt("65d1")  =&gt; 650
CInt("65d2")  =&gt; 6500
CInt("65d-1") =&gt; 6</pre>
<p>So obviously that &#8220;d&#8221; refers to &#8220;*(10 ^ following number)&#8221; &#8211; however, I can&#8217;t find a reference for that.</p>
<p>A bit of googling turns up <a href="http://icmpme.blogspot.com/2006/02/vbscript-isnumeric.asp">this page </a>, which shows that adding a space at the front doesn&#8217;t stop it from being classed as numeric.</p>
<p>The only real clue to what is going on is to read, <em>and interpret</em>, the <a href="http://msdn.microsoft.com/en-gb/library/ehs9h2x9%28VS.85%29.aspx">MSDN reference page</a> which states:</p>
<blockquote><p>Returns a Boolean value indicating whether an expression can be evaluated as a number.</p></blockquote>
<p>And there-in lies the answer &#8211; that expression can be <em>evaluated</em> as a number, not that it is a number.</p>
<p>Fortunately, there is an implementation listed on the first page which shows you an alternative way to get the job done.</p>
<p>I&#8217;m now wondering if there are other things that you can enter that will affect an number in that way. I tried</p>
<pre>CInt("6*5")</pre>
<p>but that just errored. I&#8217;m wondering whether &#8220;e&#8221; has a similar effect.</p>
<p><strong>Update</strong>: Yes, &#8220;e&#8221; (at first glance) appears to have an identical effect to &#8220;d&#8221;.</p>
<pre>CInt("65D1") =&gt; 650
CInt("65D1") =&gt; 6500
CInt("65E1") =&gt; 650
CInt("65E1") =&gt; 6500</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.armswiper.co.uk/blog/view/548/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
