From: Saga on
Using VB 2008. This seemed like a simple question. To make a short story
long...

Dim ssTest as string

Typed in ssTest<dot> expecting for Intellisense to display something like
IsNumber,
but the only method that seemed related was CompareOrdinal. I selected that
and
then used F1 for more info. This method is something totally different. I
found a few
Isxxxx methods, but none that I could use.

Next up, Google. So how much was Google my friend? In this case, not much. I
found asnwers that ranged from doing a loop and testing each string position
for
0 - 9 (ASCII 48 to 57), to using regular expressions to using the
VisualBasic
namespace function IsNumeric :-S. I also found this routine:

Public Function IsNumber(ByVal sText As String) As Boolean

If Double.TryParse(sText, Globalization.NumberStyles.AllowDecimalPoint)
Then
Return True
Else
Return False
End If

End Function

(http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/)

I am using this function for now. Doesn't VB 2008 have an inherent
function/method
for testing a string to see if it is numeric or not? Thanks! Saga


From: Tom Shelton on
On 2010-03-04, Saga <antiSpam(a)nowhere.com> wrote:
> Using VB 2008. This seemed like a simple question. To make a short story
> long...
>
> Dim ssTest as string
>
> Typed in ssTest<dot> expecting for Intellisense to display something like
> IsNumber,
> but the only method that seemed related was CompareOrdinal. I selected that
> and
> then used F1 for more info. This method is something totally different. I
> found a few
> Isxxxx methods, but none that I could use.
>
> Next up, Google. So how much was Google my friend? In this case, not much. I
> found asnwers that ranged from doing a loop and testing each string position
> for
> 0 - 9 (ASCII 48 to 57), to using regular expressions to using the
> VisualBasic
> namespace function IsNumeric :-S. I also found this routine:
>
> Public Function IsNumber(ByVal sText As String) As Boolean
>
> If Double.TryParse(sText, Globalization.NumberStyles.AllowDecimalPoint)
> Then
> Return True
> Else
> Return False
> End If
>
> End Function
>
> (http://www.janinedalton.com/blog/archives/2004/looking-for-isnumeric-in-vbnet/)
>
> I am using this function for now. Doesn't VB 2008 have an inherent
> function/method
> for testing a string to see if it is numeric or not? Thanks! Saga
>
>

IsNumeric. Though, I personally prefere to use the Double.TryParse.

--
Tom Shelton