Checking String for numerics

Cakanteptdunk

New Member
I have a string that I need to see if it contains numeric values. In classic asp, you would check for this using the method isnumeric(stringname). I haven't found a property or method on the String class to check for numerics. There has to be a way to check for numerics without parsing the string character by character. Anyone have any ideas? Thanks.This works just fine for me --<BR><BR>Sub Page_Load(sender As Object, e As EventArgs)<BR> Dim vntFoo1 As Object = "abvo3245"<BR> Dim vntFoo2 As Object = "3245"<BR> Response.Write ("vntFoo1 is numeric = " & IsNumeric(vntFoo1) & "<BR/>")<BR> Response.Write ("vntFoo2 is numeric = " & IsNumeric(vntFoo2) & "<BR/>")<BR>End SubI think that you could also do something like this...<BR><BR>Sub Page_Load (sender As Object, e As EventArgs)<BR><BR> Dim objFoo As Object = "1234e"<BR> Dim intFoo As Int32<BR><BR> Try<BR> intFoo = Int32.Parse(objFoo)<BR> Catch ex As Exception<BR> intFoo = 0<BR> End Try<BR> <BR> lblFoo.Text = intFoo.ToString()<BR><BR><BR>End Sub
 
Back
Top