Boolean conditions and exceptions, maintainability of workflow

Hi, I have several If conditions joined with And/Or. Will it read these boolean conditions from left to right? I want to check if a variable is not nothing before evaluating its contents. So if I specify the check that If variable = Nothing Or variable.ToString = “” will this work if the variable is null? (the variable itself is not a string)

My concern is that I have one If branch if variable is null, and in the other branch if it is not null, another If condition checking if it is empty string, and both of them perform the same action, I would have to place the same activity in many locations making it hard to maintain especially if I am working with many such boolean conditions.

Hi @DEATHFISH

Use “OrElse”,“AndAlso” to replace “Or”,“And” in your expression,
if you want check “Nothing” before check others and avoid right condition error.
Because right condition will be neglected, when result can be confirmed just by the left condition.
For instance,
If variable is Nothing OrElse variable.ToString = “”
If variable isNot Nothing AndAlso variable.ToString = “Test”

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.