Hello and thanks in advance for any help here. I am working on a
script that is taking information from a database with no line breaks
and passing the information through this function that I have designed
to put line breaks in near a certain column size. The ultimate
destination for the text is a text file. When I run this code on a
piece of text with carriage returns already in it the function outputs
little boxes or NewLine control chars wherever a new line needs to
happen. Does anyone know of a way to get rid of those little boxes?
Thanks in advance,
-Jason
Function HardBreak(text, col)
Dim myArray(50)
lc = 0
Do Until Len(text) < col
If InStrRev(text, vbCr, col) Then
br = InStrRev(text, vbCr, col)
myArray(lc) = Mid(text, 1, br)
text = Mid(text, br + 1)
Else
If InStr(col - 6, text, " ") < col Then
br = InStr(col - 6, text, " ")
Else
br = InStrRev(text, " ", col)
End If
myArray(lc) = Mid(text, 1, br)
text = Mid(text, br + 1)
End If
lc = lc + 1
Loop
myArray(lc) = text
lc = 0
Do Until myArray(lc) = ""
If myArray(lc + 1) = "" Then
HardBreak = HardBreak & " " & myArray(lc)
Else
HardBreak = HardBreak & " " & myArray(lc) & vbNewLine
End If
lc = lc + 1
Loop
End Function