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



The information in this article applies to:

  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP3
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP4
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP5
  • Microsoft Visual Basic Professional Edition for Windows 6.0

This article was previously published under Q290426

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.

Modification Type:MajorLast Reviewed:6/25/2004
Keywords:kbDatabase kbJET kbprb KB290426