ClipControls

NToM(), MToN()

NTOM() and its counterpart, MTON(), convert numeric values to currency and vice versa.

Usage

nNumeric = MTON( mCurrency ) mCurrency = NTOM( nNumeric )
Why the "M" in the function name, rather than a "C" for Currency? Well, "C" is already taken as the type for Character fields, so Microsoft chose "M" because it's one of the few letters that doesn't occur in the word "currency." No, actually, we suspect they chose it as shorthand for "Money." It's not intuitive, however, and violates the rules used to name other conversion functions, such as DTOT(), CTOD(), in that the type abbreviation for currency ("Y") isn't in the function name. Besides, we think that NTOY() and YTON() are cool names for functions.

These functions aren't always required. REPLACE converts one to the other automatically. A literal number can be expressed as currency by preceding it with the $ delimiter. However, if you are performing heavy mathematics like interest calculations, you'll want to convert your currency values to numeric if digits beyond four decimal places are important—they often are!

Example

REPLACE mMoneyField with NTOM(nNumerics) nRatio = MTON(mDollars)/nNumeric

See Also

CToD(), DToC(), Type()


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net