<?xml version="1.0" encoding="UTF-8"?><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"
	>
<channel>
	<title>Comments on: looking for isnumeric in vb.net?</title>
	<atom:link href="http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/</link>
	<description>Random ramblings from the home office of a web developer in Dublin, Ireland</description>
	<pubDate>Thu, 21 Aug 2008 22:42:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Carter</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/#comment-40928</link>
		<dc:creator>Carter</dc:creator>
		<pubDate>Thu, 08 May 2008 14:11:10 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-40928</guid>
		<description>Why reinvent the wheel? IsNumeric is part of .NET. Just use it.</description>
		<content:encoded><![CDATA[<p>Why reinvent the wheel? IsNumeric is part of .NET. Just use it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farren</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/#comment-10298</link>
		<dc:creator>Farren</dc:creator>
		<pubDate>Sun, 09 Sep 2007 00:44:28 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-10298</guid>
		<description>This seems to work well for me.

Public Shared Function IsNumeric(ByVal sText As String) As Boolean
        
If Double.TryParse(sText, Globalization.NumberStyles.AllowDecimalPoint) Then
    Return True
Else
    Return False
End If

End Function</description>
		<content:encoded><![CDATA[<p>This seems to work well for me.</p>
<p>Public Shared Function IsNumeric(ByVal sText As String) As Boolean</p>
<p>If Double.TryParse(sText, Globalization.NumberStyles.AllowDecimalPoint) Then<br />
    Return True<br />
Else<br />
    Return False<br />
End If</p>
<p>End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JimK</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/#comment-10053</link>
		<dc:creator>JimK</dc:creator>
		<pubDate>Thu, 23 Aug 2007 17:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-10053</guid>
		<description>ok..that didnt paste well...removed some of my code..trying again

    Public Shared Function IsNumeric(ByVal sText As String) As Boolean
        Dim b As Boolean = True
        Dim x As Integer = 0

        For x = 0 To sText.Length - 1
            Dim sChar As String = sText.Substring(x, 1)

            If Asc(sChar) &#60; 48 Or Asc(sChar) &#62; Then
                b = False
                Exit For
            End If
        Next

        Return b
    End Function</description>
		<content:encoded><![CDATA[<p>ok..that didnt paste well&#8230;removed some of my code..trying again</p>
<p>    Public Shared Function IsNumeric(ByVal sText As String) As Boolean<br />
        Dim b As Boolean = True<br />
        Dim x As Integer = 0</p>
<p>        For x = 0 To sText.Length - 1<br />
            Dim sChar As String = sText.Substring(x, 1)</p>
<p>            If Asc(sChar) &lt; 48 Or Asc(sChar) &gt; Then<br />
                b = False<br />
                Exit For<br />
            End If<br />
        Next</p>
<p>        Return b<br />
    End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JimK</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/#comment-10052</link>
		<dc:creator>JimK</dc:creator>
		<pubDate>Thu, 23 Aug 2007 17:00:10 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-10052</guid>
		<description>I get nothing but false positives with the functions listed above

I created my own and is perfect for detecting 'all numeric' values...great for detecting table indexes (just make sure you trim the text first):

    Public Shared Function IsNumeric(ByVal sText As String) As Boolean
        Dim b As Boolean = True
        Dim x As Integer = 0

        For x = 0 To sText.Length - 1
            Dim sChar As String = sText.Substring(x, 1)

            If Asc(sChar)  57 Then
                b = False
                Exit For
            End If
        Next

        Return b
    End Function</description>
		<content:encoded><![CDATA[<p>I get nothing but false positives with the functions listed above</p>
<p>I created my own and is perfect for detecting &#8216;all numeric&#8217; values&#8230;great for detecting table indexes (just make sure you trim the text first):</p>
<p>    Public Shared Function IsNumeric(ByVal sText As String) As Boolean<br />
        Dim b As Boolean = True<br />
        Dim x As Integer = 0</p>
<p>        For x = 0 To sText.Length - 1<br />
            Dim sChar As String = sText.Substring(x, 1)</p>
<p>            If Asc(sChar)  57 Then<br />
                b = False<br />
                Exit For<br />
            End If<br />
        Next</p>
<p>        Return b<br />
    End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DocXango</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/#comment-8768</link>
		<dc:creator>DocXango</dc:creator>
		<pubDate>Sun, 24 Jun 2007 00:22:48 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-8768</guid>
		<description>I've had the best luck with "\b\d+(\.\d+)?\b" as my regular expression pattern since it will match doubles and floats as well.

My variation on Kevin's function would be:
 Public Shared Function isNumeric(ByVal textToCheck as String) as Boolean
   return Regex.IsMatch(textToCheck, "\b\d+(\.\d+)?\b")
 End Function

Just a bit cleaner in my humble opinion.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve had the best luck with &#8220;\b\d+(\.\d+)?\b&#8221; as my regular expression pattern since it will match doubles and floats as well.</p>
<p>My variation on Kevin&#8217;s function would be:<br />
 Public Shared Function isNumeric(ByVal textToCheck as String) as Boolean<br />
   return Regex.IsMatch(textToCheck, &#8220;\b\d+(\.\d+)?\b&#8221;)<br />
 End Function</p>
<p>Just a bit cleaner in my humble opinion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/#comment-6962</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Tue, 06 Mar 2007 16:10:14 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-6962</guid>
		<description>The proper regex expression should be: ^\d+$
This will verify that the start of the value is numeric, not just search for any number in the supplied value</description>
		<content:encoded><![CDATA[<p>The proper regex expression should be: ^\d+$<br />
This will verify that the start of the value is numeric, not just search for any number in the supplied value</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Troy</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/#comment-5053</link>
		<dc:creator>Troy</dc:creator>
		<pubDate>Wed, 29 Nov 2006 18:25:01 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-5053</guid>
		<description>Unfortunately that regex expression doesn't work in every case.  I am parsing a file and I am getting some non-standard characters at the end of a number because of some bad data that was sent as the power failed.  This expression still returns true and my program fails as it tries to convert the number with the bad characters....</description>
		<content:encoded><![CDATA[<p>Unfortunately that regex expression doesn&#8217;t work in every case.  I am parsing a file and I am getting some non-standard characters at the end of a number because of some bad data that was sent as the power failed.  This expression still returns true and my program fails as it tries to convert the number with the bad characters&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/#comment-5047</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Wed, 29 Nov 2006 10:20:08 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-5047</guid>
		<description>oops, make that:
Public Shared Function IsNumeric(ByVal str As String) as Boolean
Return New Regex(”\d+”).Match(str).Success
End Function</description>
		<content:encoded><![CDATA[<p>oops, make that:<br />
Public Shared Function IsNumeric(ByVal str As String) as Boolean<br />
Return New Regex(”\d+”).Match(str).Success<br />
End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/#comment-5046</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Wed, 29 Nov 2006 10:19:00 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-5046</guid>
		<description>Or even simpler:

Imports System.Text.RegularExpressions

Public Shared Function IsNumeric(ByVal str As String)
        Return New Regex("\d+").Match(str).Success
    End Function</description>
		<content:encoded><![CDATA[<p>Or even simpler:</p>
<p>Imports System.Text.RegularExpressions</p>
<p>Public Shared Function IsNumeric(ByVal str As String)<br />
        Return New Regex(&#8221;\d+&#8221;).Match(str).Success<br />
    End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janine</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/#comment-1555</link>
		<dc:creator>janine</dc:creator>
		<pubDate>Sun, 12 Feb 2006 12:27:47 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-1555</guid>
		<description>thanks for the contribution peter - regular expressions to the rescue once again :)</description>
		<content:encoded><![CDATA[<p>thanks for the contribution peter - regular expressions to the rescue once again <img src='http://www.janinedalton.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>
