Hello, friends!
I've wrote some function that reduces the strings by the last symbol:
Example:
[TABLE="width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B (function)[/TD]
[TD="align: center"]B (result)[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]a+b+c+d+e+f+g+<strike></strike>[/TD]
[TD]=reducer(A1)<strike></strike>[/TD]
[TD]a+b+c+d+e+f+<strike></strike>[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]11-22-33-44-55-66-77-<strike></strike>[/TD]
[TD]=reducer(A2)<strike></strike>[/TD]
[TD]11-22-33-44-55-66-<strike></strike>[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]11-22-33-44-55-66-<strike></strike>[/TD]
[TD]=reducer(A3)<strike></strike>[/TD]
[TD]11-22-33-44-55-<strike></strike>[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]11-22-33-44-55-<strike></strike>[/TD]
[TD]=reducer(A4)<strike></strike>[/TD]
[TD]11-22-33-44-<strike></strike>[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]11-22-33-44-<strike></strike>[/TD]
[TD]=reducer(A5)<strike></strike>[/TD]
[TD]11-22-33-<strike></strike>[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]11-22-33-<strike></strike>[/TD]
[TD]=reducer(A6)<strike></strike>[/TD]
[TD]11-22-<strike></strike>[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]11-22-<strike></strike>[/TD]
[TD]=reducer(A7)<strike></strike>[/TD]
[TD]11-<strike></strike>[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]11-<strike></strike>[/TD]
[TD]=reducer(A8)<strike></strike>[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
But it works slow when the number of strings > 100k.
How to speed up this function?
Thank you in advance.
I've wrote some function that reduces the strings by the last symbol:
Code:
Function reducer(ByVal txt As String) As String
txt = Left(txt, InStrRev(Left(txt, Len(txt) - 1), Right(txt, 1)))
reducer = txt
End Function
Example:
[TABLE="width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B (function)[/TD]
[TD="align: center"]B (result)[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]a+b+c+d+e+f+g+<strike></strike>[/TD]
[TD]=reducer(A1)<strike></strike>[/TD]
[TD]a+b+c+d+e+f+<strike></strike>[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]11-22-33-44-55-66-77-<strike></strike>[/TD]
[TD]=reducer(A2)<strike></strike>[/TD]
[TD]11-22-33-44-55-66-<strike></strike>[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]11-22-33-44-55-66-<strike></strike>[/TD]
[TD]=reducer(A3)<strike></strike>[/TD]
[TD]11-22-33-44-55-<strike></strike>[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]11-22-33-44-55-<strike></strike>[/TD]
[TD]=reducer(A4)<strike></strike>[/TD]
[TD]11-22-33-44-<strike></strike>[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]11-22-33-44-<strike></strike>[/TD]
[TD]=reducer(A5)<strike></strike>[/TD]
[TD]11-22-33-<strike></strike>[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]11-22-33-<strike></strike>[/TD]
[TD]=reducer(A6)<strike></strike>[/TD]
[TD]11-22-<strike></strike>[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]11-22-<strike></strike>[/TD]
[TD]=reducer(A7)<strike></strike>[/TD]
[TD]11-<strike></strike>[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]11-<strike></strike>[/TD]
[TD]=reducer(A8)<strike></strike>[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
But it works slow when the number of strings > 100k.
How to speed up this function?
Thank you in advance.