bshipps64 bshipps64 Feb 19, 2006 - "Improved function"

== StringChop$ function ====StringChop$ function== A small function to remove any occurrences of one string from another. ---- > The brand new StringChop$ 9000!!! IT SLICES!! IT DICES!! (Does not Julienne at this time). This function simply locates the position of a 'find' string within a 'source' string, grabs everything before and after it, combines those two as a new 'source' string and repeats the process on that. Voila! Perfect potatoes every time! Delicious test program included! Enjoy! [[code format="vbnet"]] input "Original string: "; orig$ if (orig$ = "") then end [loop] input "Character(s) to chop: "; chop$ if (chop$ = "") then end orig$ = StringChop$(orig$, chop$) if (orig$ = "") then end print "Chopped string: "; orig$ goto [loop] function StringChop$(o$,c$)StringChop$(StringChop$,c$) cLen = len(c$) do cPos = instr(o$,c$,cPos) = instr(StringChop$,c$,cPos) if not(cPos) then exit do pre$ = left$(o$,cPos = left$(StringChop$,cPos - 1) post$ = mid$(o$, = mid$(StringChop$, cPos + cLen) o$ = StringChop$ = pre$ + post$ loop while 1 StringChop$ = o$ end function [[code]]