What's this operation called?

B

Bill

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.
 
J

Jason Brown [MSFT]

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.
 
B

Bill

Yep, your IIf function will do it - thanks!


Jason Brown said:
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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top