https://bugs.freedesktop.org/show_bug.cgi?id=86386
--- Comment #1 from [email protected] --- Oops! Sorry the Middle-function was buggy. Here's correction. Function Middle(sText As String, Optional lStart As Long, Optional lLen As Long, Optional sInsert As String) As String 'like Mid, but takes negative lLen which runs from left to right 'also negative lStart which are counted to the left, from the 'last position in the String i.e. the last Position ist -1 'On Error GoTo Err_Middle If IsMissing(lStart) Then lStart = 1 Dim lLenText As Long lLenText = Len(sText) If IsMissing(lLen) Then Select Case lStart Case > 0 lLen = lLenText 'get whole text up to the end of the string Case 0 lLen = lLenText + 1 Case Else lLen = -lLenText 'get whole text up to the start of the string End Select End If Dim lMidStart As Long 'start of the string to return, we intend to use the orginal Mid-function If lStart < 0 Then lMidStart = lLenText + 1 + lStart 'convert negative position to corresponding positive position Else lMidStart = lStart End If Dim lMidLen As Long 'length of the string to return If lLen < 0 Then 'the string to return is left to lMidStart lMidStart = lMidStart + 1 + lLen 'start of the string lMidLen = -lLen Else 'the string to return is right to lMidStart lMidLen = lLen End If If lMidStart < 1 Then 'start still negative, lMidLen = lMidLen + lMidStart - 1 'length must be shortened, so that we cab use thr original Mid-function lMidStart = 1 'the string to return starts from the first position End If 'if lMidLen isn't positiv, return an empty string If lMidLen < 1 Then 'we can't give a negative length to the original Mid, because ist would return the whole string sText Middle = "" Else 'ready to use the original Mid Middle = Mid(sText, lMidStart, lMidLen) End If If IsMissing(sInsert) Then Exit Function 'don't change the string sText, so we are done sText = Left(sText, lMidStart - 1) & sInsert & Mid(sText, lMidStart + lMidLen) End Function -- You are receiving this mail because: You are the assignee for the bug.
_______________________________________________ Libreoffice-bugs mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs
