Hello, how can i capture the value of left in the line below using string function:
left position is left:215px
i must capture the value 215.
Thanks...
Printable View
Hello, how can i capture the value of left in the line below using string function:
left position is left:215px
i must capture the value 215.
Thanks...
Just get the index of the colon and the index of px, and get whats inbetween.
Something along those linesCode:Dim colonIndex as Integer
Dim capLength as Integer
Dim capturedString as String
Dim dataString as String = "left position is left:215px"
colonIndex = dataString.IndexOf(":")
'Gets the length of the string inbetween the colon and px
capLength = dataString.IndexOf("px") - colonIndex
capturedString = dataString.Substring(colonIndex + 1, capLength)
Unless the format of your string is always the same (i.e the number always comes after the 1st ":" and it always has 3 digits...), in which case you can use string manipulation as shown by Cellus, you'd better have a look at regular expressions.