Click to See Complete Forum and Search --> : Searching a String for a word and Removing it???
Frans C
Nov 7th, 1999, 12:20 AM
If you are using vb6 you can use the Replace function. eg
strWords = Replace(strWords, "basic", "")
otherwise you need to use Instr in a loop to replace the word.
rino_2
Nov 7th, 1999, 11:58 AM
Hi,
I have a string called strWords and would like to click a button called cmdGo and have that button look inside the string for the word Basic and if it is found, Remove it. Will someBody please help?
Thanks
rgeorge001
Nov 9th, 1999, 04:04 AM
You could write your own function in a module such as:
code
-------------------------------------------
Public Function RemoveStr(BaseStr As String, StrToRemove As String) As String
Dim sTemp As String
On Error GoTo ErrHandler
'This ugly statement cuts the StrToRemove out of BaseStr
sTemp = Left(BaseStr, InStr(BaseStr, StrToRemove) - 1) & _
Mid(BaseStr, InStr(BaseStr, StrToRemove) + Len(StrToRemove), _
Len(BaseStr) - InStr(BaseStr, StrToRemove) + Len(StrToRemove))
RemoveStr = sTemp
Exit Function
ErrHandler:
RemoveStr = ""
Exit Function
End Function
-------------------------------------------
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.