We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question

How to attach a value to a variable

asked 2019-01-14 03:19:26 +0200

Jfi459 gravatar image

updated 2020-07-24 12:36:13 +0200

Alex Kemp gravatar image

Edit for code:

Sub Macro1
    DIM i AS integer
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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-01-14 06:18:03 +0200

Ratslinger gravatar image


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.

edit flag offensive delete link more


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.

Ratslinger gravatar imageRatslinger ( 2019-01-14 07:04:58 +0200 )edit

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

Ratslinger gravatar imageRatslinger ( 2019-01-14 17:36:42 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-01-14 03:19:26 +0200

Seen: 86 times

Last updated: Jan 14 '19