How to check if a string is not empty?

Hi all,

I’m reading a text from certain position and entering into a do while loop to work on some actions.

The text will contain different strings each time and to perfom these activies inside the do while loop the text must contain some elements every time.

If the text is empty then only it should exist the loop.

Can anyone help me with the condition to check if a var(String) is not empty so that the do while will run until the text in the position is null.

My work flow is like this

Get text from position.

Perform actions inside do while
check is text is not empty. the perform the actions again.

If empty exist do while


@batBot, You can use following condition.

Option 1:

Option 2: (if you are expecting null)
stringVariableName Is Nothing



You missed out on:
Option 3: String.IsNullOrEmpty()



Yes, That is also a good option, however String.IsNullOrWhiteSpace() covers String.IsNullOrEmpty().



Not String.IsNullOrEmpty(String)
Not String.IsNullOrWhitespace(String)

Hope the above methods helps you


A detailed note on that can be found here.


1 Like

@Nithin_P @Bhavik_Solanki @karthick

Thank you guys for your replay. But i need the opposite condition to which what you have given. :slight_smile:

The condition you provided will check if the string is empty but i need to check if the string is not empty. Since i have to use this condition inside a do while loop it has to execute some actions and then check if the string is empty for not.

If the string contains some text then it has to run the activity inside the do again and again until the string becomes empty.

I tried your condition in my do while it will not go the (do) part again even though the string in the field is not empty. It will exist the loop at the first go itself. :confused:

I tried the condition (stringVar.Length>0) and it runs in loops but it is not getting out of the loop even though the string becomes empty. :thinking:

Thanks in advance.

Just prefix condition with “Not” and you are done. (As mentioned by @karthick)
e.g. Not String.IsNullOrWhitespace(String)


@batBot Can you check what’s the Value of StringVar.Length each time inside the loop using a Write line. This way We’ll get to know What actually is the Length of the String Each time,
The Condition StringVar.Length>0 Should have worked :sweat_smile:

I checked that it return the same length every time.

@batBot Then that means it never becomes Empty :sweat_smile:, What operation are you performing to make the String Empty ?

Screenshot_2 Haha…

I check the same condition above it works but inside the do while it not.Screenshot_1

@batBot Can you tell us What is the Value of nextPageAvailable?

Next-pageVar checks if text (String) is available in a certain position or not.

Since i’m working on terminal window activities are limited

If text is available then the loop has to continue. I was analyzing the output logs and see that when the text at the position become empty the try catch is getting faulted some how. And thus the next-page var hold the previous value. I think this is why it is not stopping.

Loop 1 Output:


Loop 2 Output:


Loop 3 Output:


In loop 3 the var is holding the same value as that of the previous loop i guss it because the check activity is getting faulted since there is no text present.

This expression is giving me error
I have to use the same condition for switch case
to check whether a column contains a date or not and if it is not empty than print the date
and if it is empty than check the next case i.e. case 2