How to attach a value to a variable

Edit for code:

Sub Macro1
    DIM i AS integer
    i=3
End Sub

End Edit

Even with this simple code I can not see the value of I in watch variable.

I am new to this program but have earlier made something in SQL2000.

Hello,

You have actually asked two questions here. The first is the main question and you answered that yourself - i=3 is attaching a value to the variable i.

The next question is sort of hidden - how to debug. This is not a simple answer but I will present a short version.

When debugging you should set a break point in the code to examine information. In this case after the setting of i but before exiting; so will set on End Sub line:

image description

Also note the Watch window has i set in it (can watch multiple variables).

Now running the macro (icon or F5) stops before executing End Sub and you can see the value of i:

image description

This is just a tiny bit of debugging info. You can do much more such as setting the break point at the beginning of the code and stepping through the code one line at a time and examining various items. Please see the following for much more information:

LibreOffice Basic IDE

Integrated Development Environment (IDE)

Each of these links contain other links to further detailed information.

I should also state you can also see the value with a print or message box in the code:

Print i
MsgBox i

but I really don’t think this is what you were looking for.

You will also find a reference card on this page → BASIC Reference Cards. The LibreOffice BASIC IDE card can be of help.