新田县第一中学:在vb中 10\5.6是1 为什么不是2呢

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/07 04:43:19
为什么5\5.25=1;10\5.25=2;10\5.6=1;10\2.5=5啊?

“\”在VB是只是整除的意思,就是作除法,不计余数
如果你想在有余数时让商加一,也就是进一法可以这法作:
dim a as integer=10
dim b as integer=6
dim c as integer
if a mod b=0 then
c=a\b
else
c=a\b+1
end if

因为在VB中,\表示整除运算,其结果为整型值.

10里面最多只能放一个5.6,余下的放不下
12里面能放2个5.6,依次类推.

只有0和1 哪来得2

同意~~~~