Function IIF in VB.net
-
-
Wrong forum, you missed on both vounts, this is neither a VB nor a windows form questions. It is a SQL questions. And the answer is - there is no equivalent TSQL function to IIF. You would have to use nested if statements.
Never underestimate the power of human stupidity RAH
-
Wrong forum, and VB.NET does not have IIF, AFAIK :|
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Wrong forum, and VB.NET does not have IIF, AFAIK :|
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Are you sure VB.Net doesnt have IIF?? Thas weird, cause ive been using it lately, but i guess it must be my VS version
Alexei Rodriguez
It's there in VS2008. Learned something new today. I always thought it was just a VBA thing :-O
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
It's there in VS2008. Learned something new today. I always thought it was just a VBA thing :-O
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Use CASE statements in SQL to simulate IFF
SELECT Category =
CASE type
WHEN 'popular_comp' THEN 'Popular Computing'
WHEN 'mod_cook' THEN 'Modern Cooking'
WHEN 'business' THEN 'Business'
WHEN 'psychology' THEN 'Psychology'
WHEN 'trad_cook' THEN 'Traditional Cooking'
ELSE 'Not yet categorized'
END,
price AS Price
FROM titlesAlexei Rodriguez
-
Use CASE statements in SQL to simulate IFF
SELECT Category =
CASE type
WHEN 'popular_comp' THEN 'Popular Computing'
WHEN 'mod_cook' THEN 'Modern Cooking'
WHEN 'business' THEN 'Business'
WHEN 'psychology' THEN 'Psychology'
WHEN 'trad_cook' THEN 'Traditional Cooking'
ELSE 'Not yet categorized'
END,
price AS Price
FROM titlesAlexei Rodriguez
thanks your suggetion.Thanks so much :-D
if you cound not try then msgbox("you will lose") else msgbox("you can change yourself") end if
-
Its good to know it is in VS2008 too since its a great function Too bad VB doesnt have ?? as c# IIF is available in VS2005 too and maybe since 2003
Alexei Rodriguez
IIF has always been available to VB. The problem is that it is a function not an operator, which of course makes it nearly worthless. Starting with VS2008/VB9, the If operator was added that can be used to do the same thing as both the ?: and ?? operators depending on the number of arguments you pass.
condition ? truevalue : falsevalue
becomesIf(condition, truevalue, falsevalue)
condition ?? nullvalue
becomesIf(condition, nullvalue)
-
IIF has always been available to VB. The problem is that it is a function not an operator, which of course makes it nearly worthless. Starting with VS2008/VB9, the If operator was added that can be used to do the same thing as both the ?: and ?? operators depending on the number of arguments you pass.
condition ? truevalue : falsevalue
becomesIf(condition, truevalue, falsevalue)
condition ?? nullvalue
becomesIf(condition, nullvalue)