468,504 Members | 1,916 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,504 developers. It's quick & easy.

Replacement for IsNumeric??

Does VB .NET or the framework include a function/method that correctly
identifies the following as not being numeric?

3,6
3,,6

Assuming the decimal mark is Full Stop.

And, if the decimal mark is COMMA:

3.6 and 3..6 would be invalid

--
http://www.standards.com/; See Howard Kaikow's web site.
Nov 20 '05 #1
4 3848
* "Howard Kaikow" <ka****@standards.com> scripsit:
Does VB .NET or the framework include a function/method that correctly
identifies the following as not being numeric?


Have a look at 'Double.TryParse'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Howard Kaikow wrote:
Does VB .NET or the framework include a function/method that correctly
identifies the following as not being numeric?

3,6
3,,6

Assuming the decimal mark is Full Stop.

And, if the decimal mark is COMMA:

3.6 and 3..6 would be invalid


It's a little inefficent, but you could do something like:

public function isnumeric(str as string) as bool
try
decimal.parse(str)
return true
catch
return false
end try
end function
- Pete
Nov 20 '05 #3
Herfried K. Wagner [MVP] wrote:
* "Howard Kaikow" <ka****@standards.com> scripsit:
Does VB .NET or the framework include a function/method that
correctly identifies the following as not being numeric?


Have a look at 'Double.TryParse'.


This is the better solution; exceptions are very inefficent. I looked for
Decimal.TryParse, but didn't find it :)

- Pete
Nov 20 '05 #4
Alas, Parse has the same issue as IsNumeric, e.g., "100,14" gets converted
to 10014.

--
http://www.standards.com/; See Howard Kaikow's web site.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bv*************@ID-208219.news.uni-berlin.de...
* "Howard Kaikow" <ka****@standards.com> scripsit:
Does VB .NET or the framework include a function/method that correctly
identifies the following as not being numeric?


Have a look at 'Double.TryParse'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by eje | last post: by
4 posts views Thread by Eugene Anthony | last post: by
14 posts views Thread by Kenny | last post: by
8 posts views Thread by John Bowman | last post: by
3 posts views Thread by martin | last post: by
7 posts views Thread by Nathan Truhan | last post: by
8 posts views Thread by moondaddy | last post: by
12 posts views Thread by sck10 | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.