For this I would agree with cloud. It's not the lack of robustness in the Parse() functions. (The overloads have some pretty good power behind them) but more a fault in the UI for allowing units and other text into the numeric string.
There are a number of regular expression and/or character match functions (.IsDigit for example) that could be used to step through the string and pull out only the usable sections.
Agreed, if you're looking for the first characters that are assumed to be numeric, then you should be seeking something like
- Dim val As Double = Regex.Match(InputString, "^\d+(\.\d+)?|(\.\d+)(?=[^\D\.])").Value;
That will strip out any leading valid number. For instance 123.45.678.9 it will only pick out 123.45, likewise 123.45Hello World it will only pick out 123.45 and "123.45 Hello World" it will still only pick out 123.45.
I have to agree with one of the previous posters - this sounds like a bad design idea. A numeric input should only allow numeric input. If someone types in something else, there should be an exception raised and it should be caught and handled properly rather than compensating for bad input.