我想用round 函数对一个数值型表达进行四舍五入保留到十位,在MSDN上看的在第二个参数写上-1就可以了,可是我这样写了以后调试的时候说是"实时错误'5':无效的过程调用或参数"我把第二个参数改成正值的时候就没这样的错误了,请问Round 的第二个参数是不是不能写负数呢?但在MSDN里面确明明是这样写的呀!请各位高手帮忙解决一下!

解决方案 »

  1.   

    第二歌参数指小数点右边应该保留的位数,所以负数没法解释的。
    Round函数
          描述返回一个数值,该数值是按照指定的小数位数进行四舍五入运算的结果。语法Round(expression [,numdecimalplaces])Round函数语法有如下几部分:部分 描述 
    expression 必需的。要进行四舍五入运算的数值表达式。 
    numdecimalplaces 可选的。数字值,表示进行四舍五入运算时,小数点右边应保留的位数。如果忽略,则Round函数返回整数。 
      

  2.   

    但在msdn里面确实有在第二个参数上用负数的例子呀,而且在这个函数的定义上写的第二个参数是long型的啊这是小弟在MSDN上复制下来的Rounds a number to a specified number of digits.SyntaxROUND(number,num_digits)Number   is the number you want to round.Num_digits   specifies the number of digits to which you want to round number.If num_digits is greater than 0 (zero), then number is rounded to the specified number of decimal places.
    If num_digits is 0, then number is rounded to the nearest integer.
    If num_digits is less than 0, then number is rounded to the left of the decimal point. 
    ExamplesROUND(2.15, 1) equals 2.2ROUND(2.149, 1) equals 2.1ROUND(-1.475, 2) equals -1.48ROUND(21.5, -1) equals 20
      

  3.   

    你上面复制下来的确实有,但不是vb的帮助。她属于vfp的函数说明。
      

  4.   

    round()不好用,請用format(12.365,"#.##")
      

  5.   

    hdhai9451(※★AC米兰☆※)    可是我是要四舍五入保留到十位,用Format怎么实现呢?
      

  6.   

    ss = Format(3.12547884758752, "#0.0000000000")
      

  7.   

    msn [email protected]
    [email protected]