Stripping a string from a string

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Mark Durrenberger (durrenm_at_yahoo.com)
Date: 07/12/04


Date: Mon, 12 Jul 2004 14:14:24 -0400

I wrote a routine to strip any occurence of a character from a string (like
removing all spaces).
At the time I wrote it, I didn't think I'd be using it much and did not
worry about performance
Now I'm finding that I'm using often and wondered if there is a built in
function for doing the same thing...
My "code" is below. (please be gentle - I'm not a professional programmer
:-)

Thanks
Mark

Public Function oakStrip(StripString As String, StripChar As String) As
String
'
' strip a specified character from a string
'
Dim i As Integer
Dim strChar As String
Dim Result As String
For i = 1 To Len(StripString)
  strChar = Mid$(StripString, i, 1)
  If strChar <> StripChar Then
    Result = Result & strChar
  End If
Next i
oakStrip = Result
End Function

-- 
_________________________________________________________
Mark Durrenberger, PMP
Principal, Oak Associates, Inc, www.oakinc.com
"Advancing the Theory and Practice of Project Management"
________________________________________________________
The nicest thing about NOT planning is that failure
comes as a complete surprise and is not preceded by
a period of worry and depression.
- Sir John Harvey-Jones


Relevant Pages

  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • Re: RfD: Escaped Strings
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... \b BS (backspace, ASCII 8) ... \ ** escapes to characters much as C does. ...
    (comp.lang.forth)
  • Re: A note on computing thugs and coding bums
    ... code is valid for any character set that is legal in C (which is a ... characters in the required source character set ... A String, in C Sharp or Java, can be redefined. ... allow programmers to handle some other data format, ...
    (comp.programming)