VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Strip Characters from a string

by async tea (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This function is to strip all instances of a character out of a string. Its fairly compact and simple. Hope its helpful to someone. :)

Code Returns
The original string without the character in str2Strip

Rate Strip Characters from a string

Function stripChar(str2BStriped As String, str2Strip As String) As String
  Dim sPos As Long
  Dim newStr As String
  
  sPos = 1
  Do
    sPos = InStr(str2BStriped, str2Strip)
    If sPos > 0 Then
      newStr = newStr & Left(str2BStriped, sPos - 1)
    Else
      newStr = newStr & str2BStriped
    End If
    str2BStriped = Right(str2BStriped, Len(str2BStriped) - sPos)
  Loop Until sPos = 0
  stripChar = newStr
End Function

Download this snippet    Add to My Saved Code

Strip Characters from a string Comments

No comments have been posted about Strip Characters from a string. Why not be the first to post a comment about Strip Characters from a string.

Post your comment

Subject:
Message:
0/1000 characters