I've been using this technique in several of my programs now for quite a while and haven't had any kind of trouble with it until now. Granted now things have gotten a bit trickier but I'm still doing the same basic concept of search through a string looking for a pointer at the start and at the end of the string and then I'm copying what is in between to a new string.
Dim string1 as string, string2 as string, stringURL as string, strMid as string, strHeight as string
stringURL="<p>This is a good time for every man, woman and child to come to their wits, senses, smarts and bravery</p>"
string1 = "every"
string2 = "</p>"
loc = InStr(1, stringURL, string1)
If loc = 0 Then GoTo nxtFile
lng = Len(stringURL) - loc - 4
strMid = Right(stringURL, lng)
loc = InStr(1, strMid, string2)
If loc = 0 Then GoTo nxtFile
strHeight = Left(strMid, (loc - 1))
Msgbox strHeight
nxtFile:
End Sub
The above sentence always comes out:
every manwoman and child to come to their witssensessmarts and bravery
It always seems to remove the comma and the trailing space(where it exists).
Why is this behaving like this. I'm not sure if I've tried this without it being part of html code or not to see what happens. I need it right now though for a program that is dumping a lot of html code and shortening up the pages the make them look and feel the way I want them to.