2012-07-26 62 views

回答

1

據我所知,有沒有辦法縮短這個直接的代碼,但你可以做:

dim a,b : a =0 : b=1 ''set a = 0 & b = 1 directly 
'' Now as per your requirement 'a' value might change in script flow then you can set value as 
If a > 0 then b= 2 

希望這有助於.........

1

你可以使用single-line syntaxIf...Then...Else聲明:

If a = 0 Then b = 1 Else b = 2 
0

對於這個特定的情況下,你可以寫一個輔助函數來模仿VBA IIf功能:

Function IIf(expr, truepart, falsepart) 
    If expr Then 
     IIf = truepart 
    Else 
     IIf = falsepart 
    End If 
End Function 

b = IIf(a=0, 1, 2) 
相關問題