<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<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 a freelance web developer in Dublin, Ireland</description>
	<lastBuildDate>Thu, 29 Jul 2010 11:29:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=8736</generator>
	<item>
		<title>By: Billy Bo</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/comment-page-1/#comment-122172</link>
		<dc:creator>Billy Bo</dc:creator>
		<pubDate>Wed, 02 Dec 2009 16:17:37 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-122172</guid>
		<description>As with all VB coding, you do NOT have to import a Namspace to in order to use it. Just call that namespace.function:

Microsoft.VisualBasic.IsNumeric(expression)

Besides, as Carter says .. if you&#039;re programming in the .NET framework in VB (which if you are programming in VS2003+, then you have no choice), just inherit/import the Microsoft/System namespaces .. You have to the .NET framework installed on the computer anyways to run the program, so you don&#039;t have to worry about NOT having a particular DLL</description>
		<content:encoded><![CDATA[<p>As with all VB coding, you do NOT have to import a Namspace to in order to use it. Just call that namespace.function:</p>
<p>Microsoft.VisualBasic.IsNumeric(expression)</p>
<p>Besides, as Carter says .. if you&#8217;re programming in the .NET framework in VB (which if you are programming in VS2003+, then you have no choice), just inherit/import the Microsoft/System namespaces .. You have to the .NET framework installed on the computer anyways to run the program, so you don&#8217;t have to worry about NOT having a particular DLL</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rex the Strange</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/comment-page-1/#comment-112566</link>
		<dc:creator>Rex the Strange</dc:creator>
		<pubDate>Tue, 23 Jun 2009 16:12:57 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-112566</guid>
		<description>Why not just use the microsoft.visualbasic namespace version of isnumeric? So much easier that all this that you&#039;ve posted.</description>
		<content:encoded><![CDATA[<p>Why not just use the microsoft.visualbasic namespace version of isnumeric? So much easier that all this that you&#8217;ve posted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hong</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/comment-page-1/#comment-98725</link>
		<dc:creator>hong</dc:creator>
		<pubDate>Wed, 04 Feb 2009 07:25:03 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-98725</guid>
		<description>Use this to the textbox KeyPress event, it accept only number and maximum one &quot;.&quot; and ignore others without add into it:

    Private Sub txtMyTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSSV.KeyPress

        Select Case e.KeyChar
            Case Chr(Keys.Back)
                e.Handled = False
            Case &quot;0&quot;, &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot;, &quot;.&quot;
                Try
                    Dim strOutput As Double = 0.0
                    If Double.TryParse(txtSSV.Text &amp; e.KeyChar, strOutput) Then
                        e.Handled = False
                    Else
                        e.Handled = True
                    End If
                Catch ex As Exception
                    e.Handled = True
                End Try
            Case Else
                e.Handled = True
        End Select

    End Sub</description>
		<content:encoded><![CDATA[<p>Use this to the textbox KeyPress event, it accept only number and maximum one &#8220;.&#8221; and ignore others without add into it:</p>
<p>    Private Sub txtMyTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSSV.KeyPress</p>
<p>        Select Case e.KeyChar<br />
            Case Chr(Keys.Back)<br />
                e.Handled = False<br />
            Case &#8220;0&#8243;, &#8220;1&#8243;, &#8220;2&#8243;, &#8220;3&#8243;, &#8220;4&#8243;, &#8220;5&#8243;, &#8220;6&#8243;, &#8220;7&#8243;, &#8220;8&#8243;, &#8220;9&#8243;, &#8220;.&#8221;<br />
                Try<br />
                    Dim strOutput As Double = 0.0<br />
                    If Double.TryParse(txtSSV.Text &amp; e.KeyChar, strOutput) Then<br />
                        e.Handled = False<br />
                    Else<br />
                        e.Handled = True<br />
                    End If<br />
                Catch ex As Exception<br />
                    e.Handled = True<br />
                End Try<br />
            Case Else<br />
                e.Handled = True<br />
        End Select</p>
<p>    End Sub</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rt07</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/comment-page-1/#comment-98474</link>
		<dc:creator>rt07</dc:creator>
		<pubDate>Sat, 31 Jan 2009 23:55:50 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-98474</guid>
		<description>Integer.TryParse(MyText, MyDestNumber)
OR
if Integer.TryParse(MyText, MyDestNumber) then ...

if you need decimal values then
Double.TryParse(MyText, MyDestNumber)
OR
if Double.TryParse(MyText, MyDestNumber) then ...</description>
		<content:encoded><![CDATA[<p>Integer.TryParse(MyText, MyDestNumber)<br />
OR<br />
if Integer.TryParse(MyText, MyDestNumber) then &#8230;</p>
<p>if you need decimal values then<br />
Double.TryParse(MyText, MyDestNumber)<br />
OR<br />
if Double.TryParse(MyText, MyDestNumber) then &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: redmo</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/comment-page-1/#comment-91086</link>
		<dc:creator>redmo</dc:creator>
		<pubDate>Thu, 30 Oct 2008 23:02:14 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-91086</guid>
		<description>in the keypress event of the textbox, you could add

Dim mychar As Char
            mychar = e.KeyChar
            If IsNumerical(mychar.ToString) = True Then
            &#039;Insert positive code here
            else
            msgbox(&quot;Dammit I said numbers only&quot;)

This checks each character as its passed to the txtbox,</description>
		<content:encoded><![CDATA[<p>in the keypress event of the textbox, you could add</p>
<p>Dim mychar As Char<br />
            mychar = e.KeyChar<br />
            If IsNumerical(mychar.ToString) = True Then<br />
            &#8216;Insert positive code here<br />
            else<br />
            msgbox(&#8220;Dammit I said numbers only&#8221;)</p>
<p>This checks each character as its passed to the txtbox,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hacksign23</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/comment-page-1/#comment-90953</link>
		<dc:creator>hacksign23</dc:creator>
		<pubDate>Wed, 29 Oct 2008 22:34:58 +0000</pubDate>
		<guid isPermaLink="false">http://janinedalton.com/wp/?p=10#comment-90953</guid>
		<description>oops. here&#039;s the correct one.

public function IsNumeric(ByVal textz as string) as boolean
dim ch as boolean
for each c as byte in System.Text.Encoding.ASCII.getbytes(text)
if (48 &lt;= c &lt;= 57) then
c2 = true â€˜good job.
else
c2 = false â€˜bad job ):
return false
exit function
end if
next
return c2
end function</description>
		<content:encoded><![CDATA[<p>oops. here&#8217;s the correct one.</p>
<p>public function IsNumeric(ByVal textz as string) as boolean<br />
dim ch as boolean<br />
for each c as byte in System.Text.Encoding.ASCII.getbytes(text)<br />
if (48 &lt;= c &lt;= 57) then<br />
c2 = true â€˜good job.<br />
else<br />
c2 = false â€˜bad job ):<br />
return false<br />
exit function<br />
end if<br />
next<br />
return c2<br />
end function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carter</title>
		<link>http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/comment-page-1/#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-page-1/#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-page-1/#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) &lt; 48 Or Asc(sChar) &gt; 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 &#8211; 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-page-1/#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 &#039;all numeric&#039; 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 &#8211; 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>
</channel>
</rss>
