Hi and Happy Thanksgiving to all of you!
This is what I have tried to figure out today: I want to replace internet links in the input field of a textbox with encrypted ones before publishing the text, and everything works fine, only that it does not do anything at all towards the end of the string.
Dim headerTxt as String = [content from a textbox]
'it is no html, but for simplification, links start with "http://
Dim linkStart As String = "http://
Dim link As String 'this is what I am looking for
Dim linkLength As Integer 'how long is it?
Dim NewLink As String 'this is what I want to replace link with
Dim remainString As String 'this is the entire string minus the part in front of the current link
Dim stringIndex As Integer 'this is the index in the string we are looking at
'looping through the string to find the beginning of all links
For stringIndex = 0 To (headerTxt.Length - 8)
'did I find a link?
Index, 7) = linkStart Then
'cut away the stuff in front of the link to tidy up the code
remainString = headerTxt.Remove(0, stringIndex)
'for this bugfixing, I simplified it by stating that any link ends with a space
linkLength = remainString.IndexOf(" ")
link = remainString.Substring(0, linkLength)
NewLink = [encrypted tracking link]
headerTxt = headerTxt.Replace(link, NewLink)
Next 'go to the next stringIndex
So, what could be wrong? Why is my code not looping through to the end? It looks to me as if I would be counting the length of my string correctly, or am I not?