=Code.FineDelimiter(",",Trim(Fields!WordValues.Value),29)
Column A
-----------------------------
1234,6078,words,or,the,end,
chars, long, the, length, of
,970444, 77707,the, key, to,
how, this, works
Public Function FineDelimiter(ByVal Delimiter As String, ByVal InputString As String, ByVal MaxLen As Integer) As String
Dim FirstRow As Boolean = True
Dim Counter As Integer = 0
Dim MaxCnt As Integer = 0
Dim strHolder As String = Nothing
If InputString = Nothing Then Return Nothing
For Each matchCurrent As String In System.Text.RegularExpressions.Regex.Split(InputString, Delimiter)
Counter += matchCurrent.Length + 1
MaxCnt += matchCurrent.Length + 1
If Counter > MaxLen Then
FirstRow = False
Counter = 0
End If
If FirstRow = True Then
strHolder += matchCurrent + Delimiter
ElseIf Counter = 0 Then
If InputString.Length + 1 = MaxCnt Then
strHolder += vbNewline & matchCurrent
Else
strHolder += vbNewline & matchCurrent + Delimiter
End If
Counter = matchCurrent.Length + 1
Else
If InputString.Length + 1 = MaxCnt Then
strHolder += matchCurrent
Else
strHolder += matchCurrent + Delimiter
End If
End If
Next matchCurrent
If MaxCnt >= 2 And MaxCnt <= MaxLen Then
Return strHolder.Substring(0, strHolder.Length - 1)
Else
Return strHolder
End If
Return Nothing
End Function
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (3)
Commented:
Commented:
Author
Commented:This article (above); that I made some years ago works very easy in the print document output very little code changing.