Results 1 to 12 of 12

Thread: what would be the syntax...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    98

    what would be the syntax...

    To search a textbox for a string and then find whatever is to the right of that string?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You can use the IndexOf method to find a string inside another string or at least where the inner string starts at. The SubString method will get the string after that point.

    VB Code:
    1. Dim inner As String = "the"
    2.         Dim whole As String = "back in the valley..."
    3.         MsgBox(whole.Substring(whole.IndexOf(inner)))
    4.         'returns 'the valley...'

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    98
    Sweet.... now with that, am i able to set it so it only finds so many chars after the keyword?

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Yeah, check out the help in the SubString method. You can pass a 2nd parameter in which is the length from the start to return.

    VB Code:
    1. Dim inner As String = "the"
    2.         Dim whole As String = "back in the valley..."
    3.         MsgBox(whole.Substring(whole.IndexOf(inner), 5))
    4.         'returns 'the v'

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    98
    Thank you SO much for your help so far

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    98
    I think this should be the last one

    I have this string:

    <html><head><title>VN Boards - *users* Profile</title>

    I want to get just the username, which can be up to 20 chars, how can i get from the beginning to the end?

  7. #7
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    What you want to do is get the text between the - and the space after the name. Soo....
    VB Code:
    1. Dim sText As String
    2. Dim sUser As String
    3. Dim iStart As Integer
    4. Dim iEnd As Integer
    5. sText = "<html><head><title>VN Boards - *users* Profile</title>"
    6. iStart = sText.IndexOf("-") + 1 ' add one for the space
    7. iEnd = sText.LastIndexOf(" ") ' last space will be between user and profile
    8. sUser = sText.Substr(iStart, iEnd - iStart).Trim()

    untested, should work.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    98
    Cool sun, it works... Can i use the same method to get this?
    Code:
    		Posts Total:
    		&nbsp;</td>
    		<td width=85% class="BoardRowB">
    		6,499 
    keep in mind, the number is always changing

    Ive tried numerous things, but cant seem to get it

  9. #9
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    it should be dead easy as long as u know what appears after that number, so you can look for the <td width=85% class="BoardRowB"> and then for the thing that is after it , subtract to get the lenght of the number and then use the .substring() method
    \m/\m/

  10. #10

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    98
    heh... actually thats a bit tough....


    everything uses

    <td width=85% class="BoardRowB"> in it

  11. #11
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    be smart, look for references, like the 5th's <td width=85% class="BoardRowB"> or something like that
    \m/\m/

  12. #12

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    98
    heh... i got it, i looked from posts total, and then looked so many spaces in until the number started and ended at the space after the number

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