访问字典的另一种方法
问题描述:
这里是我的代码,我正在寻找一种不同的方式来访问一个字典,这是一个替代这个因为一个*。尽管调试和设置断点,但无法找到错误。当我用
昏暗教育作为新词典的词典(字符串列表(字符串))访问字典的另一种方法
效果很不错,但是这一次是给我的问题。你有什么建议?
checkWord = replacements.Keys.ElementAt(nextCheckIndex)
foundIndex = RichTextBox1.Find(checkWord, 0, RichTextBoxFinds.WholeWord)
If foundIndex > -1 Then
ContextMenuStrip1.Items.Clear()
For Each replacement In replacements(checkWord)
答
Private Sub CheckForReplacementText()
Dim foundIndex As Integer = 0
Dim start As Integer = 0
Try
For Each checkWord In replacements.Keys
foundIndex = RichTextBox1.Find(checkWord, start, RichTextBoxFinds.WholeWord)
If foundIndex > -1 Then
ContextMenuStrip1.Items.Clear()
For Each replacement In replacements(checkWord)
ContextMenuStrip1.Items.Add(replacement, Nothing, Sub(sndr As Object, ea As EventArgs)
RichTextBox1.SelectedText = GetWordWithOutBracketedText(kamau)
End Sub)
ContextMenuStrip1.Show(RichTextBox1, RichTextBox1.GetPositionFromCharIndex(RichTextBox1.SelectionStart + RichTextBox1.SelectionLength))
Next
End If
Next
Catch e As Exception
MessageBox.Show(e.ToString)
End Try
End Sub
+0
额外下一个不应该在那里,但为了更正。谢谢。但是当你在这里删除这部分时,它不显示上下文菜单:'Else nextCheckIndex = nextCheckIndex + 1 CheckForReplacementText() End If'你能帮我吗?这就好像该部分对于运行该程序非常重要。 –
什么错误,你在说什么?你有什么问题?我不是一个心灵读者,我没有一个水晶球来看你的屏幕。请你应该精确地解释你的错误,上面的代码中没有任何内容似乎是错误的。 – Steve
@steve。我在这里得到了一个*:** foundIndex = RichTextBox1.Find(checkWord,0,RichTextBoxFinds.WholeWord)** –
_checkWord_的值是什么?你确定这个单词出现在richtextbox文本中吗?没有理由使用Find查找*异常。尝试使用调试器,并在达到异常之前检查变量的值。顺便问一下,你确定这个异常是*Exception,而不是来自前一行(ElementAt .....) – Steve