README.md

December 5, 2022 ยท View on GitHub

Strip Characters from a string

Description

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

More Info

The original string without the character in str2Strip

Submitted On
Byasync tea
LevelBeginner
User Rating4.8 (19 globes from 4 users)
CompatibilityVB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
CategoryString Manipulation
WorldVisual Basic
Archive File

Source Code

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