Prev: Help with clickonce deployment over VPN - Am I the only person on earth doing this?
Next: How do I determine IF string is number?
From: Saga on 4 Mar 2010 13:41 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 4 Mar 2010 14:41
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 |