2008-11-20 21 views
12

這是晶體的如何,如果然後其他人打造一個水晶字符串中使用報告公式

關於水晶報表公式語法簡單的問題的方式報告9在Visual Studio 2003中:我如何建立一個使用公式的結果如果那麼子句?

具體來說,我想是這樣的:

dim val as string 
val = {table.level} 
if {table.uom_id} = 5 then 
    val = val & ' feet' 
else 
    val = val $ ' meters' 
end if 

和val應該是公式的結果。

只要我們在這裏,有沒有寫這些的捷徑?這些非常冗長,三元操作員會很受歡迎。

回答

17

你的例子很接近。只需使用Crystal語法,如下所示:

stringvar val := {table.level}; 

if {table.uom_id} = 5 then 
    val := val + ' feet' 
else 
    val := val + ' meters'; 

//to return a value, just plop it down at the end 
val 

但是,如果你想要的東西多一點簡潔,使用:

if {table.uom_id} = 5 then 
    {table.level} + ' feet' 
else 
    {table.level} + ' meters'; 
+0

謝謝,這是一個總的疼痛 – 2008-11-20 21:34:53