|
-
Feb 4th, 2011, 03:02 PM
#1
Thread Starter
Junior Member
help to capture a value in line
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...
-
Feb 4th, 2011, 04:18 PM
#2
Addicted Member
Re: help to capture a value in line
Just get the index of the colon and the index of px, and get whats inbetween.
Code:
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)
Something along those lines
-
Feb 4th, 2011, 04:28 PM
#3
Re: help to capture a value in line
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.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|