IsNumeric() function returns True
if the data type of Expression is
Boolean, Byte,
Decimal, etc or an Object
that contains one of those numeric types, It
returns a value indicating whether an expression can be converted to a numeric data type.
It also returns True if
Expression is a Char or
String that can be successfully converted to a number.
IsNumeric returns
False if Expression is
of data type Date or of data type
Object and it does not contain a numeric type, It has to do with the
format/type of the data, not the actual value of the data. And "NaN" I believe
is technically of type float. IsNumeric returns
False if Expression is
a Char or String that
cannot be converted to a number.
Example:
using
Microsoft.VisualBasic;
using
System;
using
System.Collections;
using
System.Collections.Generic;
using
System.Data;
using
System.Diagnostics;
public
class Sample
{
public static
void Main()
{
string Data1 =
null;
System.Text.StringBuilder
Output = new System.Text.StringBuilder();
Output.AppendLine(string.Format("IsNumeric({0})
... {1}", Data1, Information.IsNumeric(Data1)));
Output.AppendLine();
Data1 = "-11.1231";
Output.AppendLine(string.Format("IsNumeric({0})
... {1}", Data1, Information.IsNumeric(Data1)));
Output.AppendLine();
Data1 = "October 21, 1987";
Output.Append(string.Format("IsNumeric({0})
... {1}", Data1, (Data1 == null)));
Console.WriteLine(Output.ToString());
Console.ReadLine();
}
}
Output:
Have a nice Coding