by Xavior Gates (2 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 23rd April 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
You can use this module to add one string to another at set intervals or at a specified position without writing over any text that currently
'AddToString Module by Xavior Gates'
Public Function AddToStringAtIntervals(ByVal theString As String, ByVal theReplacement As String, ByVal theInterval As Long) As String
j = 0
Dim theStringParts(0 To 100) As String
firstRun = True
For i = 1 To Len(theString) Step theInterval
theStringParts(j) = Mid(theString, i, theInterval)
j = j + 1
Next i
theString = vbNullString
For i = 0 To j
If firstRun = True Then
theString = theStringParts(i)
firstRun = False
Else
theString = theString + theReplacement + theStringParts(i)
End If
Next i
For i = Len(theString) - Len(theReplacement) + 1 To Len(theString)
Mid(theString, i) = " "
Next i
AddToStringAtIntervals = RTrim(theString)
End Function
Public Function AddToStringAtIndex(ByVal theString As String, ByVal theReplacement As String, ByVal theIndex As Long) As String
Dim theStringParts(0 To 1) As String
theStringParts(0) = Mid(theString, 1, theIndex)
theStringParts(1) = Mid(theString, theIndex + 1)
theString = vbNullString
theString = theStringParts(0) + theReplacement + theStringParts(1)
AddToStringAtIndex = theString
End Function
No comments have been posted about You can use this module to add one string to another at set intervals or at a specified position wi. Why not be the first to post a comment about You can use this module to add one string to another at set intervals or at a specified position wi.