IIf函數在評估表達式時分析真實部分和假部分我是否缺少任何東西?試試這個聲明,讓我知道!IIf函數解析
例子:
Dim sample = ""
Dim result = IIf(String.IsNullOrWhiteSpace(sample), 0, Integer.Parse(sample))
Exception = "Input string was not in a correct format."
修復:從MSDN文檔
Dim result = Integer.Parse(IIf(String.IsNullOrWhiteSpace(sample), 0, sample))
http://msdn.microsoft.com/en-us/library/27ydhh0d(v=VS.71).aspx
是的,這是正確的。 'IIF'只是一個函數 - 函數總是在執行之前評估它們的參數。您鏈接的MSDN頁面上的*備註/備註*甚至明確地說明了這一點。你的問題是什麼? – Amadan 2012-01-03 11:39:52
[爲什麼不能作爲IIF函數工作,但會作爲IF語句?](http://stackoverflow.com/questions/3701787/why-wont-this-work-as-an-iif - 功能 - 但意志-AS-AN-if語句) – Curt 2012-01-03 11:54:32