Re: [VBA ] IIF指令的溢位
推
04/23 16:57,
04/23 16:57
→
04/23 16:57,
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)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):