Results 1 to 3 of 3

Thread: [RESOLVED] LastIndexOf count problem?

  1. #1

    Thread Starter
    New Member VBNetUser84's Avatar
    Join Date
    Feb 2007
    Posts
    10

    Resolved [RESOLVED] LastIndexOf count problem?

    I have a web page source and want to extract some info. I have this:

    Code:
            Dim strText As String, intPos1 As Integer = 0, intPos2 As Integer = 0
    
            strText = rtBox1.Text
    
            While intPos2 < strText.Length
                intPos1 = strText.IndexOf("<h>", intPos1)
                intPos2 = strText.LastIndexOf("</h>", intPos1)
                MsgBox(intPos1 & " " & intPos2)
                'MsgBox(Mid(strText, intPos1 + 3, intPos2), MsgBoxStyle.Information)
                If intPos2 = -1 Then Exit While
                intPos2 = (intPos2 + 1)
            End While
    The problem is this: intPos2 = strText.LastIndexOf("</h>", intPos1)
    if I remove the ", intPos1" from LastIndexOf it works but I want to continue in the text but if I place a Integer after "("</h>", X)" I get -1 as result = no match?? Thanks for clearing this out

  2. #2
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: LastIndexOf count problem?

    LastIndexOf will start at your intPos1 and count backwards toward the beginning of the string. Is that what you are looking for?

  3. #3

    Thread Starter
    New Member VBNetUser84's Avatar
    Join Date
    Feb 2007
    Posts
    10

    Re: LastIndexOf count problem?

    Ahh see my mistake now when I got some sleep thanks for the help!

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