|
-
April 25th, 2001, 10:37 AM
#1
iif statements vs if then
I want to know why VB insists on executing both the true and false part of a iif statment when it should only do one part.
Example:
If nTotOutput = 0 then
fLinearity = 0
else
fLinearity = (1 - (nTotDev / nTotOutput))
End If
fLinearity = IIf(nTotOutput = 0, 0, (1 - nTotDev / nTotOutput)))
Both of these bits of code should do the same thing however the iif statement will produce an error when nTotOutput = 0 because of the division by 0 problem. Why must VB check that part of the statement when it is going to return the other part anyway?
-K
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|