Visual Basic Loop innertext

Posted on 2012-08-25
Last Modified: 2012-08-25
I would like to change this so that it will loop for every number found after SKU# until it reaches the end of the innertext.

Dim skuTag As String = "SKU #"
        Dim index As Integer = curElement.InnerText.ToUpper.IndexOf(skuTag)
        If index <> -1 Then

            Dim SKU As String = curElement.InnerText.Substring(index + skuTag.Length).Split(" ")(0)

        End If

Open in new window

Question by:-Geek
    LVL 85

    Accepted Solution

    Here's one way:
            Dim skuTag As String = "SKU #"
            Dim data As String = curElement.InnerText.ToUpper
            Dim spaceIndex As Integer
            Dim skuIndex As Integer = data.ToUpper.IndexOf(skuTag)
            While skuIndex <> -1
                spaceIndex = data.IndexOf(" ", skuIndex + skuTag.Length)
                If spaceIndex <> -1 Then
                    Dim SKU As String = data.Substring(skuIndex + skuTag.Length, spaceIndex - (skuIndex + skuTag.Length))
                    skuIndex = data.IndexOf(skuTag, spaceIndex)
                End If
            End While

    Open in new window

    LVL 1

    Author Closing Comment

    Thank you so much, I hope you have enjoyed my thinking around asking a new question, and not trying to add more on to what you have helped me solve.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now