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!

Verify data is a number.

Summary: Sometimes you want to verify that the data you enter really is a number. If it isn't default the value to 0.
 
Keywords: CDBL
CINT
CLNG
FIXNUMBER
ISNUMERIC
NUMBER
Applicable Software: Active Server Pages (ASP)
 
Body:

It's important to validate that data is what you expect it to be. This function takes a parameter and if it is a number, it converts it to a double and returns it. If it is not a number, it returns 0. There is now a .NET version of the FixNumber function.

Function FixNumber(ByVal numberToFix)
Dim m_lOut
	m_lOut = Trim(numberToFix & "")
	If Len(m_lOut) = 0 Then
		m_lOut = 0
	ElseIf Not IsNumeric(m_lOut) Then
		m_lOut = 0
	Else
		m_lOut = CDbl(m_lOut)
	End If
	
	FixNumber = m_lOut
	
End Function

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 3/5/2002 11:39:04 AM

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

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.