Replacement for IsNumeric??

  • Thread starter Thread starter Howard Kaikow
  • Start date Start date
H

Howard Kaikow

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
 
* "Howard Kaikow said:
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'.
 
Howard said:
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
 
Herfried said:
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
 
Alas, Parse has the same issue as IsNumeric, e.g., "100,14" gets converted
to 10014.
 
Back
Top