by Agron Kovaci (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 23rd December 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Parting Text Function
ByVal lLenPart As Long, _
Optional sDelimiter As String = " ", _
Optional bEnabledEvent As Boolean = True) As String
If Len(sText) = 0 Then GoTo NoParting
If lLenPart <= 0 Or lLenPart >= Len(sText) Then GoTo NoParting
Dim sMidText As String
Dim sTextOut As String
Dim sTemp As String
Dim lLen As Long
On Error GoTo NoParting
sTemp = Mid$(sText, 1, lLenPart)
For lLen = lLenPart + 1 To Len(sText) Step lLenPart
sMidText = Mid$(sText, lLen, lLenPart)
sTextOut = sDelimiter & sMidText
sTemp = sTemp & sTextOut
If bEnabledEvent Then DoEvents
Next
PartingText = sTemp
Exit Function
NoParting:
PartingText = sText
End Function