# Example of Using a Do While Activity

> To exemplify how to use a **Do While** activity, let’s create an automation that increments an integer variable from 0 to 10, and displays a message every time it is incremented.

To exemplify how to use a **Do While** activity, let’s create an automation that increments an integer variable from 0 to 10, and displays a message every time it is incremented.

1. Create a new sequence.
2. Create an integer variable, `Counter`, with a default value of 0.
3. Add a **Do While** activity to the **Designer** panel.
4. In the **Body** section, add an [Assign](https://docs.uipath.com/activities/docs/assign) activity.
5. Select the **Assign** activity and in the **To** field, add the `Counter` variable.
6. In the **Value** field, type `Counter` + 1. This helps you increment the value of the variable with one.
7. Add a [Write Line](https://docs.uipath.com/activities/docs/write-line) activity, under the **Assign** one.
8. On the right side of the **Text** field, select **Plus** ![docs image](https://documentationpicturerepo.blob.core.windows.net/screenshots/screenshots/2020.4_StudioX/plus_menu.png) &gt; **Open in Advanced Editor**.
9. Inside the **Expression Editor** window, type "The counter is " + `Counter.ToString`. This writes the value of the counter in the **Output** panel each time it is incremented.
10. In the **Condition** section of the **Do While** activity, type `Counter` &lt; 10. The body of the **Do While** activity is repeated until the value of the `Counter` variable is bigger than 10.
    The project should look as in the following screenshot.

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-167221-b4d24448.webp)

11. Press F5. The automation is executed. Note that the **Output** panel displays the message indicated in the **Write Line** activity.

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-169001-cdba20ab.webp)

[Download example](https://documentationexamplerepo.blob.core.windows.net/examples/Studio_v2022.10/DoWhileActivity.zip)
