?
Solved

Visual Basic Loop innertext

Posted on 2012-08-25
2
Medium Priority
?
629 Views
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)
            MsgBox(SKU)

        End If

Open in new window

0
Comment
Question by:-Geek
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 38333511
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))
                Debug.Print(SKU)

                skuIndex = data.IndexOf(skuTag, spaceIndex)
            End If
        End While

Open in new window

0
 
LVL 1

Author Closing Comment

by:-Geek
ID: 38333524
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

621 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