Quote Originally Posted by Shaggy Hiker
I'd be inclined to keep using it in this case. There are a whole crowd of replacements for Val, but I don't know a clean replacement for IsNumeric. Replacing a built-in function with a self-rolled function just doesn't seem very satisfying.
The reason Double.TryParse was created in the first place was to improve the performance of IsNumeric. Originally IsNumeric called Double.Parse and caught the exception if it failed. This was a slow process and if IsNumeric failed a lot it created significant lag. They therefore created the Double.TryParse method to speed things up.

It was such a hit that they decided to add similar methods to other types. The IsDate function now uses Date.TryParse as well.

One issue with IsNumeric is that it parses the value to determine whether it is a valid representation of a number. That means that doing something like this:
vb.net Code:
  1. If IsNumeric(myString) Then
  2.     myNumber = Convert.ToDouble(myString)
  3. End If
is wasteful because you're parsing the same string twice. If you only want to know whether a value is numeric or not then IsNumeric is cool, but if you actually want the numeric value then don't use it. It uses Double.TryParse internally so just use Double.TryParse yourself.

The other issue is that you cannot specify any format for what's acceptable in a number. In general this is not an issue but but in many cases you need the flexibility of a TryParse method, which lets you specify the type to convert to and the formats that are acceptable.