<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Wrong behavior of Basic "mid" statement"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=126913#c5">Comment # 5</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Wrong behavior of Basic "mid" statement"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=126913">bug 126913</a>
              from <span class="vcard"><a class="email" href="mailto:serval2412@yahoo.fr" title="Julien Nabet <serval2412@yahoo.fr>"> <span class="fn">Julien Nabet</span></a>
</span></b>
        <pre>With this patch:
diff --git a/basic/source/runtime/methods.cxx
b/basic/source/runtime/methods.cxx
index fe266fdc009c..777b21040230 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -1159,7 +1159,7 @@ void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite)

                 OUStringBuffer aResultStr = aArgStr;
                 sal_Int32 nErase = nReplaceLen;
-                aResultStr.remove( nStartPos, nErase );
+                aResultStr.remove( nStartPos, nErase - nStartPos);
                 aResultStr.insert(
                     nStartPos, aReplaceStr.getStr(), std::min(nReplaceLen,
nReplaceStrLen));

it works.
But this unit test fails:
    s = "The lightbrown fox"
    Mid(s, 5, 10, "lazy")
it expects:
"The lazy fox"
but with the patch I get:
"The lazyrown fox"

Perhaps, I could use "nErase - nStartPos" only when using VBASupport 1
but:
1) Still I don't know if the patch is right
2) Changing behaviour of mid function may bring some regressions for some other
users

=> There's no more Basic expert in
<a href="https://wiki.documentfoundation.org/FindTheExpert">https://wiki.documentfoundation.org/FindTheExpert</a>, so I'm a bit stuck.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>