Summary: | With "Option VBASupport 1" arguments should be treated as ByValue by default (not as ByRef) | ||
---|---|---|---|
Product: | LibreOffice | Reporter: | Rafael Lima <rafael.palma.lima> |
Component: | BASIC | Assignee: | Not Assigned <libreoffice-bugs> |
Status: | NEW --- | ||
Severity: | normal | CC: | aron.budea, himajin100000 |
Priority: | medium | ||
Version: | 7.3.5.2 release | ||
Hardware: | All | ||
OS: | All | ||
See Also: |
https://bugs.documentfoundation.org/show_bug.cgi?id=150727 https://bugs.documentfoundation.org/show_bug.cgi?id=101631 |
||
Whiteboard: | |||
Crash report or crash signature: | Regression By: | ||
Bug Depends on: | |||
Bug Blocks: | 108908 |
Description
Rafael Lima
2022-09-16 18:29:44 UTC
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 ========== |