无限递归替代 [英] Infinite recursion in replacement
本文介绍了无限递归替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在此代码中避免替换中的无限递归?你可以在这里找到我的研究文件:
研究 - 词汇表 - Google文档 [ ^ ]
而不是再次调用CheckForReplacementText()函数。我试图调用foundIndex + = 1,但它无法正常工作。这可能是什么问题,因为当我尝试使用它时,它无法工作。当我再次调用该函数时,它只能在它之前检查5次。
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
replacements(parts(0)).Add(parts(1))
Else
Dim newWordList As New List(Of String)
newWordList.Add(parts(1))
replacements.Add(parts(0), newWordList)
End If
Loop
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
Try
Dim checkWord As String = replacements.Keys.ElementAt(nextCheckIndex)
Dim foundIndex As Integer = RichTextBox1.Find(checkWord, 0, RichTextBox1.TextLength, RichTextBoxFinds.WholeWord)
推荐答案
仅回答从未答复的清单:由OP解决。
是的,我解决了这个问题。现在我正在处理其他事情
Answered only to remove from unanswered list: solved by OP.
"Yes, I solved the problem. Now am just working on other things"
这篇关于无限递归替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文