leighhobson89
New Member
- Joined
- Aug 25, 2016
- Messages
- 36
I'm having a blank moment.
Once a string variable has been set, I basically need to check it for certain substrings within it, and get rid of them, and join the string back up. It will mainly be getting rid of any occurrences where there is a double, concurrent occurrence of "%2B" in the string, i.e. "%2B%2B"
Can someone just tell me how to pull that out, replace it with "%2B" i.e. one occurrence, and leave the rest of the string as it is.
Dead simple I'm sure, but it has to be in VBA to slot into my code.
I am basically along these lines, but clearly its wrong or I wouldn't be writing on here:
Thanks for your help in advance
Once a string variable has been set, I basically need to check it for certain substrings within it, and get rid of them, and join the string back up. It will mainly be getting rid of any occurrences where there is a double, concurrent occurrence of "%2B" in the string, i.e. "%2B%2B"
Can someone just tell me how to pull that out, replace it with "%2B" i.e. one occurrence, and leave the rest of the string as it is.
Dead simple I'm sure, but it has to be in VBA to slot into my code.
I am basically along these lines, but clearly its wrong or I wouldn't be writing on here:
Code:
searchString = Replace(searchString, " ", "%2B")
posOfDoubleSpace = InStr(1, searchString, "%2B%2B")
Do While posOfDoubleSpace <> 0
posOfDoubleSpace = InStr(1, searchString, "%2B%2B")
right = searchString
searchString = Left$(searchString, posOfDoubleSpace - 1) + "%2B"
lengthSearchStringLeft = Len(searchString)
right = right$(right, Len(right) - lengthSearchStringLeft)
Loop
Thanks for your help in advance