Search Tools Links Login

Remove several chars!

Posted: 2003-06-01
By: ArchiveBot
Viewed: 67

Filed Under:

VB6 Code Cache

No attachments for this post

It removes a set of chars from a string, by using ParamArray, it is very simple! It was submitted as a alternative to another submission :

Original Author: Brian Kristensen


Text, char1, char2 .... etc.


It is simple and fast


It returns the string without the chars that is defined.

Side Effects



Public Sub TestIt()
Dim sText As String
sText = InputBox("Please write something you want to remove 'e;s;n;t' from!", "Remove Char test", "It doesent work!")
MsgBox RemoveChar(sText, "e", "s", "n", "t")
End Sub
Public Function RemoveChar(ByVal sText As String, ParamArray sChar()) As String
Dim lngdo As Long
For lngdo = LBound(sChar) To UBound(sChar)
  sText = Replace(sText, sChar(lngdo), "")
Next lngdo
RemoveChar = sText
MsgBox "Removed: " & Join(sChar, ";")
End Function

Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.