VB Code:
Dim maxl As Integer, mystr As String, s, mystart As Integer, pos As Integer, mychar As String Dim i As Integer maxl = 3 mystart = 1 pos = 1 mystr = "qqqqqqqqqweeeerrrrrrrtttttttttyyuuuuuuuuuiiiiiooooooooppppppppp" For i = 1 To Len(mystr) mychar = String(maxl + 1, Mid(mystr, i, 1)) pos = InStr(i, mystr, mychar) If Not pos = 0 Then If pos = i Then mystr = Left(mystr, i + maxl - 1) & Right(mystr, Len(mystr) - i - maxl) & Mid(mystr, i, 1) i = i - 1 End If End If Next Debug.Print mystr
try this
pete




Reply With Quote