Dim i As Double i = 4 MsgBox Int(i) + Sgn(i - Int(i)) i = 4.1 MsgBox Int(i) + Sgn(i - Int(i)) i = 4.5 MsgBox Int(i) + Sgn(i - Int(i))
fountion newnum(x as double) as int If x> Int(x) Then newnum=Int(Text1.Text) + 1 Else newnum=Int(Text1.Text) End If end fountion
fountion newnum(x as double) as integer If x> Int(x) Then newnum=Int(Text1.Text) + 1 Else newnum=Int(Text1.Text) End If end fountion 不好意思,类型少写几个字母,用惯了VC
function newnum(x as double) as integer If x> Int(x) Then newnum=Int(Text1.Text) + 1 Else newnum=Int(Text1.Text) End If end function 不好意思,类型少写几个字母,用惯了VC
expression 必需的。要进行四舍五入运算的数值表达式。
numdecimalplaces 可选的。数字值,表示进行四舍五入运算时,小数点右边应保留的位数。如果忽略,则Round函数返回整数。
Dim TempSng as Single
TempSng=Int(n)
if n=TempSng then
MyIntUp=TempSng
Else
MyIntUp=TempSng+1
End if
End Function
谢谢支持,不过最好你看清楚我问的。要是这样写,谁都会。
本示例说明 Int 及 Fix 函数在返回某数值的整数部分时有何不同。当参数为负数时,Int 函数返回小于或等于该参数之最大整数,而 Fix 函数则返回大于或等于该参数之最小整数。Dim MyNumber
MyNumber = Int(99.8) ' 返回 99。
MyNumber = Fix(99.2) ' 返回 99。MyNumber = Int(-99.8) ' 返回 -100。
MyNumber = Fix(-99.8) ' 返回 -99。MyNumber = Int(-99.2) ' 返回 -100。
MyNumber = Fix(-99.2) ' 返回 -99。
i = 4
MsgBox Int(i) + Sgn(i - Int(i))
i = 4.1
MsgBox Int(i) + Sgn(i - Int(i))
i = 4.5
MsgBox Int(i) + Sgn(i - Int(i))
If x> Int(x) Then
newnum=Int(Text1.Text) + 1
Else
newnum=Int(Text1.Text)
End If
end fountion
If x> Int(x) Then
newnum=Int(Text1.Text) + 1
Else
newnum=Int(Text1.Text)
End If
end fountion
不好意思,类型少写几个字母,用惯了VC
If x> Int(x) Then
newnum=Int(Text1.Text) + 1
Else
newnum=Int(Text1.Text)
End If
end function
不好意思,类型少写几个字母,用惯了VC
function MyInt(a as long)
if a>fix(a) then MyInt=a+1
end function
Round(x-0.00000...001)+1
x = 3.99999999999999...6的时候答案是多少?TO:mjcom(风声水起) 我地意思你地明白?判断地不要。不看清要求,斯拉斯拉地!
3+1=4不过我觉得这样虽然简单,但是做判断绝对比做浮点运算的运行效率高!
Dim i As Longi = 0 - Int(0 - s)OK了
i = -Int(-s)