WelcomeServicesPortfolioKnowledge BaseContact Us
27 Seconds, Inc.


Knowledge base View Article

need hosting?

Need hosting? We use and love our host - CrystalTech.com!
Need hosting? We use and love our host - CrystalTech.com!

Text Disguise - CAPTCHA-image/Human Interactive Proof web services

National Holiday Dates and Bank Holiday Dates - web site that provides the dates of national and bank holidays for the United States, United Kingdom, Ireland and Scotland

Holiday Web Service - web services for programmers to provide the dates of national and bank holidays in their applications for the United States, United Kingdom, Ireland and Scotland

Our Family Heart - web site to help families communicate no matter where they are

What?! You haven't heard about the greatest remote controlled flyer to come out in years?! Checkout the FlyTech DragonFly now!

IsNumeric Function Replacement

Summary: IsNumeric allows some strange forms of numbers that you wouldn't think are valid. This function filters out those.
 
Keywords: DOUBLE
EXPONENT
INT
ISNUMERIC
Applicable Software: Active Server Pages (ASP)
 
Body:

Recently, a post on the AspMessageBoard.com triggered a thread about why the built-in IsNumeric() function returned True for the value "33e1".

The answer is because 33e1 is scientific notation for a larger number. But, unfortunately the database didn't care for this "number" much and returned an error during the insert.

So, I set out to write a simple IsNumeric() function replace. This is what I came up with:

Function myIsNumeric(var) 
Dim bOut 
Dim dTMP 
    bOut = IsNumeric(var) 
    If bOut Then 
        dTMP = CDbl(var) 
        bOut = CBool(Trim(dTMP & "") = Trim(var & "")) 
    End If 

    myIsNumeric = bOut 

End Function 

And, to use the function, you would do:

thevar = "22" 
thevar = "4333d4" 
If myIsNumeric(thevar) Then 
  Msgbox "it is" 
Else 
  Msgbox "not" 
End If

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 5/8/2002 5:15:30 AM

Rate this article: Average: n/a
n/a12345678910
Comments?

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.