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:

    a?b:c

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

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

    Thanks,

    Bill.
    Bill, Dec 15, 2004
    #1
    1. Advertising

  2. it's not available in VBScript

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

    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
    else
    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
    rights.


    "Bill" <> wrote in message
    news:...
    > 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:
    >
    > a?b:c
    >
    > Which translates to:
    > If a = TRUE then
    > return b
    > else
    > return c
    > end If
    >
    > Can anyone help me with this??? I need this for an ASP script.
    >
    > Thanks,
    >
    > Bill.
    >
    >
    >
    >
    >
    >
    >
    Jason Brown [MSFT], Dec 15, 2004
    #2
    1. Advertising

  3. Bill

    Bill Guest

    Yep, your IIf function will do it - thanks!


    "Jason Brown [MSFT]" <> wrote in message
    news:...
    > it's not available in VBScript
    >
    > it's called the 'ternary' or 'trinary' operator - depending on who you

    talk
    > to.
    >
    > 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
    > else
    > 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
    > rights.
    >
    >
    > "Bill" <> wrote in message
    > news:...
    > > 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:
    > >
    > > a?b:c
    > >
    > > Which translates to:
    > > If a = TRUE then
    > > return b
    > > else
    > > return c
    > > end If
    > >
    > > Can anyone help me with this??? I need this for an ASP script.
    > >
    > > Thanks,
    > >
    > > Bill.
    > >
    > >
    > >
    > >
    > >
    > >
    > >

    >
    >
    Bill, Dec 15, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Apricot
    Replies:
    4
    Views:
    504
    velthuijsen
    Apr 16, 2004
  2. david ullua
    Replies:
    13
    Views:
    636
  3. raan
    Replies:
    2
    Views:
    431
  4. Weng Tianxiang
    Replies:
    6
    Views:
    576
    glen herrmannsfeldt
    Sep 12, 2007
  5. Buzz Lightyear
    Replies:
    10
    Views:
    1,096
    Alexander Bartolich
    Aug 12, 2009
Loading...

Share This Page