Rounding in MS Access

后端 未结 12 684
夕颜
夕颜 2020-11-28 14:23

Whats the best way to round in VBA Access?

My current method utilizes the Excel method

Excel.WorksheetFunction.Round(...

But I am l

12条回答
  •  攒了一身酷
    2020-11-28 15:07

    Int and Fix are both useful rounding functions, which give you the integer part of a number.

    Int always rounds down - Int(3.5) = 3, Int(-3.5) = -4

    Fix always rounds towards zero - Fix(3.5) = 3, Fix(-3.5) = -3

    There's also the coercion functions, in particular CInt and CLng, which try to coerce a number to an integer type or a long type (integers are between -32,768 and 32,767, longs are between-2,147,483,648 and 2,147,483,647). These will both round towards the nearest whole number, rounding away from zero from .5 - CInt(3.5) = 4, Cint(3.49) = 3, CInt(-3.5) = -4, etc.

提交回复
热议问题