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.