Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Give me length of decimal places.
Message
From
08/06/1998 03:48:26
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, United Kingdom
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00105714
Message ID:
00105715
Views:
24
>Hi Folks,
>
> My requirement is to know the number of decimal places in a numeric expression.
>For example
>
>Passing 123.456 should return 3
> 13.234533 should return 6
>
>Thanks in advance
>
>Jayesh
Hi,
Here's a function to do what you want. It could be done as a one-line expression but it would be quite long.

FUNCTION LenDecimals
LPARAMETER tnTestNum
LOCAL lcNumber, lnPos, lnResult

lcNumber = LTRIM( PADL( tnTestNum, 99))
lnPos = AT( ".", lcNumber)
IF lnPos = 0
lnResult = 0
ELSE
lnResult = LEN( lcNumber) - lnPos
ENDIF

RETURN lnResult
Regards
Mark

Microsoft VFP MCP
Menulib - OO Menus for VFP www.hidb.com/menulib
Previous
Reply
Map
View

Click here to load this message in the networking platform