Results 1 to 3 of 3

Thread: help to capture a value in line

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    27

    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...

  2. #2
    Addicted Member cellus205's Avatar
    Join Date
    Dec 2010
    Location
    San Antonio, TX
    Posts
    237

    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

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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
  •  



Click Here to Expand Forum to Full Width