Does VBA Have a Ternary Operator?

前端 未结 3 802
感动是毒
感动是毒 2020-12-16 10:13

I come from the beautiful world of Obj C, which is based on the C programming language, and I\'ve fallen in love with finding quirky ways to save space. However, I\'ve looke

3条回答
  •  星月不相逢
    2020-12-16 10:58

    As an alternative you can create the following public function in a module:

    Public Function iff(expr, trueR, falseR) As Variant
        If expr Then iff = trueR Else iff = falseR
    End Function
    

    So far works for me.

提交回复
热议问题