KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q290426: PRB: Round() Function Does Not Accept Negative Parameters

Article: Q290426
Product(s): Microsoft Visual Basic for Windows
Version(s): 6.0,6.0 SP3,6.0 SP4,6.0 SP5
Operating System(s): 
Keyword(s): kbDatabase kbJET kbMDAC kbGrpDSVBDB kbGrpDSMDAC kbDSupport
Last Modified: 23-JUL-2001

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Visual Basic Enterprise Edition for Windows, versions 6.0, 6.0 SP3, 6.0 SP4, 6.0 SP5 
- Microsoft Visual Basic Professional Edition for Windows, version 6.0 
-------------------------------------------------------------------------------

SYMPTOMS
========

If you use a negative number for the second parameter of the Round function, the
function returns the following error message:

  Runtime Error 5: Invalid procedure call or argument.

CAUSE
=====

The Round function does not accept negative numbers for the second parameter.
The second parameter indicates the number of decimal places that should be
returned. By design, the expression service calls Visual Basic for Applications
(VBA) to evaluate Round.

MORE INFORMATION
================

Steps to Reproduce Behavior
---------------------------

1. Open a project in Visual Basic 6.0.

2. Paste the following code into the Immediate window:

  Debug.Print Round(2.45, 1) 'returns 2.4.
  Debug.Print Round(2.45, -1) 'returns the error

3. Press ENTER after each line to see the evaluation of the function. The second
  line, which contains the negative number, returns the above-mentioned error
  message.

Additional query words: run-time

======================================================================
Keywords          : kbDatabase kbJET kbMDAC kbGrpDSVBDB kbGrpDSMDAC kbDSupport 
Technology        : kbVBSearch kbAudDeveloper kbZNotKeyword6 kbZNotKeyword2 kbVB600Search kbVB600 kbVB600SP3 kbVB600SP4 kbVB600SP5
Version           : :6.0,6.0 SP3,6.0 SP4,6.0 SP5
Issue type        : kbprb

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.