This ticket is a spinoff from bug 150727. LibreOffice's Basic implementation assumes that arguments are defined as ByRef (see [1]). So in LO the code below prints "Y" as a result, which is correct. Sub Test() Dim a As String a = "X" DummySub (a) MsgBox (a) End Sub Sub DummySub(val As String) val = "Y" End Sub [1] https://help.libreoffice.org/7.4/en-US/text/sbasic/shared/03090409.html However, in MS VBA, arguments are passed as ByValue by default, hence the code above using Option VBASupport 1 should print "X" in LibreOffice, but we still get "Y" as a result. If you run the code above in MSO you'll get an "X" as result.
In MS VBA, arguments are passed BYREF as default. (Documentation claims that VB.NET is different). In MS VBA the test case shown creates a temporary reference by using an expression DummySub (a) The expression (a) is created, referenced, updated to 'Y', and discarded. Subsequent use of the variable a is not affected by the discarded (expression) To demonstrate the same behavior using Call syntax: Call DummySub( (a) ) Wrapping a variable in () creates an expression. The CALL syntax requires call brackets, which are not expression brackets.
In LO, the statement DummySub (a) Does NOT create and discard a reference. Rather, it acts the same way as the CALL syntax LibreOffice: DummySub(a) is the same as Call DummySub(a). MS VBA: DummySub (a) is NOT the same as Call DummySub(a) LibreOffice: DummySub2(a,b) is NOT a syntax error. MS VBA: DummySub2(a,b) IS a syntax error. MS VBA: Call DummySub2(a,b) is NOT a syntax error. LibreOffice: Call DummySub2( (a), b) is the same as Call DummySub2( a,b) MS VBA: Call DummySub2( (a), b) is NOT the same as Call DummySub2( a,b) ========== sub Test() Dim a As String,b a = "X" call DummySub2((a),b) MsgBox (a) End Sub Sub DummySub2(val As String,b) val = "Y" End Sub ==========
Dear Rafael Lima, To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the information from Help - About LibreOffice. If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice. Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to 'inherited from OOo'; 4b. If the bug was not present in 3.3 - add 'regression' to keyword Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-UntouchedBug
*** This bug has been marked as a duplicate of bug 101631 ***