Esta função tem a capacidade de inserir quebras nas linhas, a partir de um carácter identificado.
Function BreakTextAtX (varOriginal As Variant, _Optional strBreakCharacter As String = " ", _Optional lngMaxLength As Long = 72) As VariantDim strNewString As String, strWorking As String, strPart As StringDim strOriginalNoCrLf As StringDim lngPosition As Long, lngHold As Long, lngLength As LongDim lngWorkLength As LonglngLength = Len(varOriginal & "")If lngLength > 0 ThenLet strOriginalNoCrLf = Replace(Replace(CStr(varOriginal), vbCr, ""), _vbLf, "")Let strNewString = ""Let lngPosition = 1Do While lngPosition <= lngLengthLet strWorking = Mid(strOriginalNoCrLf, lngPosition, lngMaxLength)Let lngWorkLength = Len(strWorking)If lngWorkLength < lngMaxLength ThenIf Len(strNewString) > 0 And Len(strWorking) > 0 Then _Let strNewString = strNewString & vbCrLfLet strNewString = strNewString & strWorkingExit DoElseLet lngHold = InStrRev(strWorking, strBreakCharacter)If lngHold = 0 Then lngHold = lngWorkLengthIf Len(strNewString) > 0 Then _Let strNewString = strNewString & vbCrLfLet strNewString = strNewString & Left(strWorking, lngHold)Let lngPosition = lngPosition + lngHoldEnd IfLoopLet BreakTextAtX = strNewStringElseIf IsNull(varOriginal) = True ThenLet BreakTextAtX = varOriginalElseLet BreakTextAtX = ""End IfEnd IfEnd Function
Tags: Access, break, 72, quebra, linha, insere, carriage return, character,line feed,
Nenhum comentário:
Postar um comentário