Automatic type conversion in Visual Basic 6.0

前端 未结 5 1584
自闭症患者
自闭症患者 2021-01-13 06:13

When we convert a float to integer in visual basic 6.0, how does it round off the fractional part? I am talkin about the automatic type conversion.

If we assign like

5条回答
  •  情歌与酒
    2021-01-13 06:38

    The VB6 Round() function uses a Banker's Rounding method. MS KB Article 225330 (http://support.microsoft.com/kb/225330) talks about this indirectly by comparing VBA in Office 2000 to Excel's native behavior and describes it this way:

    When a number with an even integer ends in .5, Visual Basic rounds the number (down) to the nearest even whole number. [...] This difference [between VBA and Excel] is only for numbers ending in a .5 and is the same with other fractional numbers.

    If you need different behavior, I'm afraid you'll have to have to specify it yourself.

提交回复
热议问题