Skip to content

Instantly share code, notes, and snippets.

@Phuseos
Last active August 26, 2016 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Phuseos/5720839d25db1849d61c74f775aec862 to your computer and use it in GitHub Desktop.
Save Phuseos/5720839d25db1849d61c74f775aec862 to your computer and use it in GitHub Desktop.
Using the IIf() function as a Nested Conditional (?:) Operator (VBA / C#)
'Using the IIf() function as a Nested Conditional (?:) Operator
'Quick view of how you can use the iif function as the nested conditional operator, used in C#
'In C#
string TestString;
//string = Condition == true ? if true -> TestString = "Value" : else (false) -> TestString = null;
TestString = Condition ? "Value" : Convert.ToString(null);
'In VBA
dim TestString As String
'string = Condition = true ? Gets "Value" on true, Else gets vbEmpty (Null)
TestString = IIf((Condition = true), "Value", vbEmpty)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment