How to delete a string in another comma delimited string
Posted on September 27, 2011
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 'String Manipulation - How to delete a string in another comma delimited string Public Function DeleteElement(ByVal strtext As String, strDelimiter As String, _ Optional ByVal intRemoveElementNo As Integer = 0) Dim strFinalText As String Dim strElements() As String Dim I As Integer strElements = Split(strtext, strDelimiter) For I = LBound(strElements) To UBound(strElements) If Not I = intRemoveElementNo Then If Not I = UBound(strElements) Then strFinalText = strFinalText & strElements(I) & strDelimiter Else strFinalText = strFinalText & strElements(I) End If End If Next I DeleteElement = strFinalText 'Debug.Print DeleteElement End Function 'How to call this procedure: 'msgbox DeleteElement ("1, 12, 55, 5,4" , ",", 0) |