Variable is not declared

Hi I am a fresher in UI path, learning through online . Just installed UI Path Studio and tried to create activities, variables etc. While i apply run i am getting error that “Variable is not declared. it may be inaccessible due to its protection level”

Please help me to solve this

Be sure that it’s available in that scope. You can see available variables in the variables panel, where you can also change their scopes.

Create a variable in the variable pane available in the bottom of Uipath studio designer page

  1. Create a variable
  2. scope of variable is very important

Thank you so much.

The transcript of the video i followed is given here.

The first method of creating variables is from the context menu or with a keyboard shortcut. Note that Variables cannot be created if the Designer panel does not contain at least one activity, so let’s drag in a Sequence and add a Message Box.

In the Properties panel of the Message Box, right-click a field that can be edited, and select Create Variable from the context menu, or press Ctrl+K.

A Set Name field is displayed. Let’s write “myMessage” and press Enter. The variable is created. You may not use spaces when naming a variable, so capitalization is useful to distinguish a new word. As you become more advanced UiPath users, you will surely develop your own unique naming sequence for variables. Note that When creating variables like this, the type is automatically generated,

Depending on the selected property. As you can see here, “myMessage” was automatically created as generic value. The second method of creating variables is from the Variables panel.

In the Designer panel, click Variables then click the Create Variable line. A new variable with the default value is displayed. Note that when creating variables like this, the default type are String variables.

Using the Variables Panel you can view and edit the name, type and scope of each variable.

The scope of the variables is set when you create the variable and it is based on the activity that was highlighted when the variable was created.

Let’s see this in action. If we select “Sequence 1” and we click on Create Variable, the scope is set to “Sequence 1”, but if we click on “Sequence within Sequence” and we click on Create Variable, the scope is set to “Sequence within Sequence”.
The scope of the variable is important because the variable will only be recognized within the specified scope.

Using the Properties panel to create a variable has the same behavior regarding the scope of the created variable.

In the Variable Panel you can also set a Default value for the variables. Let’s set the default value for Variable1 to “Hello”.

Now that we have a default value, let’s drag in a Message Box and add Variable1 as Text for the Message Box.

Next, let’s create a new variable for the Output Property and let’s call it “buttonText”.

Now let’s drag in a new Message Box to display the variable “buttonText”.
And finally let’s run the program. We get the default value of the first variable and after we press ok, we see that the Button Text was saved in the variable and we displayed it.

In this video we’ve learned what variables are, the importance of the variables, how they are created, and how we can edit them. We also went through a short demo on how to use a variable.

And i got error that Button Text is not declared.

thank you. i am not able to change scope as only one scope is displayed

can you please share the screenshot of variables Pane

When i tried again what i understood is the variable created in Properties Panel is not getting captured in the Variable tab of bottom portion. I created again the variable tab and it is working now.

Screenshot is shared here

Variable can be created by three ways

  1. Ctrl + K
  2. IN Variable Pane
  3. click create variable option in Right click or choosing in the top menu

Can you please me how you created variable?

Ctrl+K is not working for me.
First i tried with 3rd option. it is getting displayed in main window but not in variable pane.
Then i tried with 2nd option. it is working