Results 1 to 3 of 3
  1. #1
    CraigR is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    27

    Rounding a visual basic calculation Please

    Hi
    Any help would be great, the calculation actually returns 0.750 however I need to round it up to .8

    Me.XpectRHeight = AveCutFill / 1000 & Round(1, 0)

  2. #2
    Join Date
    Apr 2017
    Posts
    1,673
    With Visual Basic you mean VBA?

    To get the result rounded to whole number, the formula must be
    Code:
    =ROUND(AveCutFill/1000,0)
    To get the result rounded to 1st decimal, the formula must be
    Code:
    =ROUND(AveCutFill/1000,1)
    , etc.


    But you have to remember, that Access VBA uses 'banker's rounding':
    Round(0.5,0) = 0, Round(1.5,0) = 2, Round(2.5,0) = 2, etc.
    More about 'banker's rounding' and how to avoid it you can read e.g. here https://www.techonthenet.com/access/...eric/round.php

    NB! This behavior of ROUND() function applies to VBA only! E.g. Excel worksheet function ROUND() rounds in traditional way.

  3. #3
    CraigR is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    27
    Mate
    Thank you!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help with Rounding in Visual Basic
    By UTLee in forum Programming
    Replies: 4
    Last Post: 12-16-2014, 05:05 PM
  2. Visual Basic
    By Darth21 in forum Access
    Replies: 4
    Last Post: 08-11-2014, 06:18 AM
  3. Visual Basic
    By kwooten in forum Queries
    Replies: 2
    Last Post: 01-25-2012, 08:22 AM
  4. Can't find Visual Basic
    By Art Burger in forum Programming
    Replies: 0
    Last Post: 04-20-2011, 05:35 PM
  5. Can't see visual basic code
    By Michele Keck in forum Forms
    Replies: 5
    Last Post: 09-29-2010, 11:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums