作者IamCoolKing (我是冷王!!!)
看板Visual_Basic
标题Re: [VBA ] IIF指令的溢位
时间Fri Apr 24 15:58:10 2009
1F:推 MOONRAKER:对,iif既为函数,那麽每个参数都要在传进函数前先算完 04/23 16:57
2F:→ MOONRAKER:而这一算之下,会错的当然就先signal error了 04/23 16:57
M大说的很对
原po可以看一下MS msdn里的说明
http://msdn.microsoft.com/en-us/library/27ydhh0d(VS.71).aspx
Note The expressions in the argument list can include function calls.
As part of preparing the argument list for the call to IIf, the Visual Basic
compiler calls every function in every expression. This means that you cannot
rely on a particular function not being called if the other argument is
selected by Expression.
VB compiler 会先把每一个传入参数编译过,所以在这情况下,
虽然第一种叙述方式看样子好像是有排除分母为零的状况,但实际上,
compiler都会try两种状况,因而造成除以零的溢位。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.117.177.29
※ 编辑: IamCoolKing 来自: 59.117.177.29 (04/24 15:59)