[RESOLVED] Split by count of characters
I want split text by count of characters to arLines for example:
Original text:
Splited text by 3 characters:
Quote:
AAA
AAA
AAA
AAA
AA
Now I'm using this:
Quote:
arLines = Split(Test1.Text, "x")
For i = 0 To UBound(arLines)
'Misc code
Next i
This works good but before spliting I have put "x" every 3 characters in Textbox.
So maybe there is an way how can I split text by count to arLines not by "x" ?
Re: Split by count of characters
Code:
Public Function SplitLen(ByRef Text As String, ByVal Chars As Long) As String()
Dim strOut() As String, lngA As Long, lngPos As Long
If Chars >= 1 Then
ReDim strOut((Len(Text) - 1) \ Chars)
For lngA = 1 To Len(Text) - Chars Step Chars
strOut(lngPos) = Mid$(Text, lngA, Chars)
lngPos = lngPos + 1
Next lngA
strOut(lngPos) = Mid$(Text, lngA)
SplitLen = strOut
Else
SplitLen = Split(vbNullString)
End If
End Function
Re: Split by count of characters
Thanks Merri good code :thumb:
[RESOLVED]