# Variable condition in if statement

**URL:** <https://forum.kirupa.com/t/variable-condition-in-if-statement/247276>\
**Category:** Uncategorized\
**Created:** [December 20, 2007, 3:15pm UTC](https://forum.kirupa.com/t/variable-condition-in-if-statement/247276 "2007-12-20T15:15:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mart212](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@mart212](https://forum.kirupa.com/u/mart212)\
**Post date:** [December 20, 2007, 3:15pm UTC](https://forum.kirupa.com/t/variable-condition-in-if-statement/247276/1 "2007-12-20T15:15:13Z")

</div>

Hi

It looks like this may not be possible but…

I would like to code a variable condition in a if statement.  
For example I have an if statement that will sometimes use one condition and sometimes two conditions.

If(var == 1){  
//do something  
}

Or

If(var2 == 3){  
//do something  
}

Or

If(var == 1 and var2 == 3 ){  
//do something  
}

So I would like to know if I can construct the condition before with something like this

var condition:String = “var == 1 and var2 == 3”;  
If([condition]) {  
//do something  
}

Thanks in advance

Martin
