dim a,b,c a=inputbox("a","please input") b=inputbox("b","please input") c=CInt(a)+CInt(b) msgbox(c)
另一个是昵称为“乱码”的人给出的:
复制代码 代码如下:
dim a,b,c a=int(inputbox("a","please input")) b=int(inputbox("b","please input")) c=a+b msgbox c
很显然,一个用了CInt函数,一个用了Int函数。
CInt Function
复制代码 代码如下:
When the fractional part of a value is exactly 0.5, the CInt function rounds to the closest even number. For example, 0.5 rounds to 0, 1.5 rounds to 2, and 3.5 rounds to 4. CInt differs from the Fix and Int functions, which truncate, rather than round, the fractional part of a number.
Both Int and Fix remove the fractional part of number and return the resulting integer value.
The difference between Int and Fix is that if number is negative, Int returns the first negative integer less than or equal to number, whereas Fix returns the first negative integer greater than or equal to number. For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.