VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Remove several chars

by Brian Kristensen (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

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 : https://www.vbcoders.com/vb/scripts/showcode.asp?txtCodeId=39842&lngWId=1

Inputs
Text, char1, char2 .... etc.
Assumes
It is simple and fast
Code Returns
It returns the string without the chars that is defined.
Side Effects
No

Rate Remove several chars

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

Download this snippet    Add to My Saved Code

Remove several chars Comments

No comments have been posted about Remove several chars. Why not be the first to post a comment about Remove several chars.

Post your comment

Subject:
Message:
0/1000 characters