Advertisement
C_Volume2 String Manipulation #74144

A Function that removes all of a chr from a string

This is a fairly basic code, but I had someone ask me how to do it, so I figured since I made it I might as well post it. Basicly this is a simple function which you can add to either a bas, or a form, and then you call it, and it removes all occurenses of a character within a string. IE.(My name is steve) if you wanted to remove all the spaces you could use this.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Function RemoveChar(sText As String, sChar As String) As String
  Dim iPos As Integer, iStart As Integer
  Dim sTemp As String
  iStart = 1
  Do
    iPos = InStr(iStart, sText, sChar)
    If iPos <> 0 Then
      sTemp = sTemp & Mid(sText, iStart, (iPos - iStart))
      iStart = iPos + 1
    End If
  Loop Until iPos = 0
  sTemp = sTemp & Mid(sText, iStart)
  RemoveChar = sTemp
End Function

'The code could then be called like this
Call RemoveChar(Text1.text, " ")
'This will rmove all the spaces from the textbox
'named Text1
'I hope this helps some people out. I have actualy
'surprisignly enought had 37 requests from visitors
'to my site for this code.
Upload
Original Comments (3)
Recovered from Wayback Machine