Click here to Skip to main content
15,669,526 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How do you avoid infinite recursion in replacements in this code? You can find my research file here:

Research-wordlist - Google Docs[^]

Instead of calling the CheckForReplacementText() function again. I have tried to call the foundIndex +=1 but it is not working. What could be the problem here because, when I try to use it, it cannot work. When I call the function again it can only check 5 times before it hands.

Imports System.IO
Imports System
Imports System.Collections.Generic
Public Class Form1

    Dim replacementWords As List(Of String)()
    Private replacements As New Dictionary(Of String, List(Of String))

    Private nextCheckIndex As Integer

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Using reader As New StreamReader("C:\Users\Acer\Desktop\Text Files\output10.txt")
            Do Until reader.EndOfStream
                Dim parts = reader.ReadLine().Split("|"c)

                If replacements.ContainsKey(parts(0)) Then
                    Dim newWordList As New List(Of String)
                    replacements.Add(parts(0), newWordList)
                End If

        End Using

        RichTextBox1.Text = "You provided a bad advice, irregardless of your intention. You provided a bad advice, irregardless of your intention. "
    End Sub
    Private Sub CheckForReplacementText()
        If nextCheckIndex = replacements.Count Then
            MessageBox.Show("Check complete.")
        End If

            Dim checkWord As String = replacements.Keys.ElementAt(nextCheckIndex)

            Dim foundIndex As Integer = RichTextBox1.Find(checkWord, 0, RichTextBox1.TextLength, RichTextBoxFinds.WholeWord)
Updated 25-May-16 22:52pm
ZurdoDev 22-Jan-16 8:14am    
All you have to do is step through and debug it.
[no name] 22-Jan-16 8:41am    
Like this:

"Put the whole code here and debug it?

Catch e As Exception
MessageBox.Show("Error occurred: " & e.ToString)
End Try
ZurdoDev 22-Jan-16 8:50am    
No, debugging means putting a breakpoint somewhere where it makes sense, then stepping through the code one line at a time and analyzing the values in your variables. If you do that, you'll see exactly what the problem is.
[no name] 22-Jan-16 8:41am    
Can you help alittle?
ZurdoDev 22-Jan-16 8:49am    
I'm trying to, but I can't run your code. However, you could find the problem very quickly if you stepped through your code one line at a time. Then you can see exactly what is happening.

1 solution

Answered only to remove from unanswered list: solved by OP.
"Yes, I solved the problem. Now am just working on other things"
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900