Cuts the left or Middle part of string without breaking words
Can specify number of chars to cut from left, or from where to start and for how long for the mid part.
CutString_Words_Left could be identical to CutLeft http://codeder.com/Dev/Browse/?ID=39AXA8D7PQ
Found in xLib from ANmars.com
Function CutString_Words_Left(Text, Characters)
' Cuts from a string respecting words, without breaking words, until a space or enter or end of string is found
CutString_Words_Left =Text
If Text="" then Exit function
if len(Text) <=Characters then Exit function
NewT=left(Text,Characters)
for i=len(NewT)-1 to 1 step -1
Cha1=mid(NewT,i,1)
Cha2=mid(NewT,i,2)
CondAny=Cha1=" " or Cha1="." or Cha1="," or Cha1=chr(10)
CondAny=CondAny or Cha1=":" or Cha1=";" or Cha1="-"
CondAny=CondAny or Cha2=chr(13)
if CondAny then
NewT=Left(Text,i)
Exit for
end if
next
CutString_Words_Left =NewT
End Function
Function CutString_Words_Mid(Text, CharsStart, Characters)
' Cuts words from string, respects words, without breaking words
'
CutString_Words_Mid=Text
If Text="" then Exit function
if len(Text) <=Characters then Exit Function
if len(Text) <CharsStart then Exit function
NewT=Left(Text, Characters)
For i=TStart to 1 step-1
If Mid(Text,i,2)=vbcrlf Then
NewT=Mid(Text,i, TLen)
Exit For
End If
Next
For i=len(NewT)-1 to 1 step -1
If Mid(NewT,i,2)=vbcrlf Then
NewT=Left(NewT,i)
Exit for
End if
Next
CutString_Words_Mid=NewT
End Function
' Cuts from a string respecting words, without breaking words, until a space or enter or end of string is found
CutString_Words_Left =Text
If Text="" then Exit function
if len(Text) <=Characters then Exit function
NewT=left(Text,Characters)
for i=len(NewT)-1 to 1 step -1
Cha1=mid(NewT,i,1)
Cha2=mid(NewT,i,2)
CondAny=Cha1=" " or Cha1="." or Cha1="," or Cha1=chr(10)
CondAny=CondAny or Cha1=":" or Cha1=";" or Cha1="-"
CondAny=CondAny or Cha2=chr(13)
if CondAny then
NewT=Left(Text,i)
Exit for
end if
next
CutString_Words_Left =NewT
End Function
Function CutString_Words_Mid(Text, CharsStart, Characters)
' Cuts words from string, respects words, without breaking words
'
CutString_Words_Mid=Text
If Text="" then Exit function
if len(Text) <=Characters then Exit Function
if len(Text) <CharsStart then Exit function
NewT=Left(Text, Characters)
For i=TStart to 1 step-1
If Mid(Text,i,2)=vbcrlf Then
NewT=Mid(Text,i, TLen)
Exit For
End If
Next
For i=len(NewT)-1 to 1 step -1
If Mid(NewT,i,2)=vbcrlf Then
NewT=Left(NewT,i)
Exit for
End if
Next
CutString_Words_Mid=NewT
End Function
Text, Characters
Or
Text, CharsStart, Characters
Or
Text, CharsStart, Characters
Views 3,405
Downloads 1,350
CodeID
DB ID
ANmarAmdeen
602
Revisions
v1.0
Wednesday
August
8
2018