I'm trying to build an user interface based on keywords from a text file. My search can now determine the index of each key word I apply. What I'd like to be able to do is then pull those indexes in numerical order from the textbox I saved them to.

I.E.

index value = 0
Do until "endoftextbox"
    'search textbox for next index value
    'Do something with this
Loop

Here is what I have so far,

    Sub ShallReadRoutine()
        Dim keywords() = {"shall read", "Power", "J-IC", "Factory Default"}
        Dim i As Integer
        For Each key As String In keywords


            i = Procedure.IndexOf(key)
            Do Until i = Procedure.LastIndexOf(key)
                RichTextBox1.AppendText(i)
                RichTextBox1.AppendText(" " + key)
                RichTextBox1.AppendText(Environment.NewLine)
                i = Procedure.IndexOf(key, i + 1)
            Loop
        Next key

    End Sub

Can someone help?

There is a Read-Only Lines Property that is an array of strings that represent the lines in the textbox. You should be able to iterate through that, something like this:

For I=0 to RichTextBox1.Lines.Length-1
    'Access the specific line like this, RichTextBox1.Lines(I)
    'And you can use the 'RichTextBox1.Lines(I).Contains("Some String")' method to see if a certain string is present
Next
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.