Ask Your Question
1

How to attach a value to a variable

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

Jfi459 gravatar image

updated 2019-01-14 06:26:03 +0100

Ratslinger gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

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

Ratslinger gravatar image

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.

edit flag offensive delete link more

Comments

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 +0100 )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 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 36 times

Last updated: Jan 14