Home > How-To Library > String Manipulation

How to delete a string in another comma delimited string

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
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)

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.