View Full Version : Show only remainder


bill crumpton
04-23-2001, 09:55 AM
I am doing a long division in an unbound field and would like a certain unbound field to show only the remainder of the division not the whole number. For example, if unbound field [Text 2] is dividing 327 by 11 I want unbound field [Text 4] to show only the .8 remainder of that division problem. Any help is greatly appreciated.

BAC

AlanS
04-23-2001, 11:01 AM
Use this code:

[Text 4] = 327 Mod 11

bill crumpton
04-23-2001, 11:18 AM
Alan,
Thanks for response and this does capture the remainder, however it is rounding up. Any way to get just the first number after the decimal point without rounding up? Thanks.\\BAC

AlanS
04-23-2001, 11:40 AM
Do you want the remainder, or the fractional part of the quotient (not the same thing)? There is no "rounding up" going on - the Mod operator gives you the remainder of an integer division, which is itself always an integer. If you want the fractional part of the quotient (0.727272... in your example), use this:

[Text 4] = (327 / 11) - (327 \ 11)

Note that the forward slash performs regular division and the backslash performs integer division (discarding the remainder), and the difference between them is the fractional part you want. To get only the first digit without rounding, use:

[Text 4] = Int((327 / 11) - (327 \ 11) * 10)

You can find other ways of performing this kind of manipulation by reviewing the help topics on the CInt, CLng, Fix, Int, Mod and Format functions.

[This message has been edited by AlanS (edited 04-23-2001).]

bill crumpton
04-23-2001, 12:07 PM
Sorry Alan, the first response was correct. Thanks for your help.

BAC