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.
Printable View
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.
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
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
-------------------------------------------