What's this operation called?

Discussion in 'ASP General' started by Bill, Dec 15, 2004.

  1. Bill

    Bill Guest

    Looking thru my books, searching the 'net - I think it's a VBScript feature.

    I don't know the exact operators, but it's something like:


    Which translates to:
    If a = TRUE then
    return b
    return c
    end If

    Can anyone help me with this??? I need this for an ASP script.


    Bill, Dec 15, 2004
    1. Advertisements

  2. it's not available in VBScript

    it's called the 'ternary' or 'trinary' operator - depending on who you talk

    it's available in C#, VB.NET, JScript and various other languages, but not
    VBScript. in VBScript I'd use an IIf function (which isn't native so you
    have to include your own)

    Function Iif(condition, truereturn, falsereturn)
    If condition = true then
    Iif = truereturn
    Iif = falsereturn
    end if
    End Function

    then call

    Iif(somethingorother="true", "something", "somethingelse")

    Jason Brown
    Microsoft GTSC, IIS

    This posting is provided "AS IS" with no warranties, and confers no
    Jason Brown [MSFT], Dec 15, 2004
    1. Advertisements

  3. Bill

    Bill Guest

    Yep, your IIf function will do it - thanks!

    Bill, Dec 15, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.