访问字典的值 [英] Accessing the values of a dictionary
本文介绍了访问字典的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
单击按钮时,我试图访问字典中的值.这是一个有效的方法,因为代码未突出显示,并且给了我这个错误:
I am trying to access the values in a dictionary when I click a button. Is this a valid method because the code is not highlighting, and it is giving me this error:
InvalidArgument =值"-8"对于开始"无效.
参数名称:开始
错误来自这里:
RichTextBox1.Select(startA - Word.Length, Word.Length)
但是当我使用类似这样的内容时:将单词As String设为暗== 坏" 正在起作用.
But when I use something like this: Dim word As String = "bad" it is working.
Dim startA As Integer? 'where to start next time, or Nothing in the first time
Private Sub BtnSearch_Click(sender As System.Object, e As System.EventArgs) Handles BtnSearch.Click
Dim nextCheckIndex As Integer = 0
Dim Word As String = replacements.Keys.ElementAt(nextCheckIndex)
If startA.HasValue Then 'Did you have a previous result? We need to turn it back to black
RichTextBox1.Select(startA - Word.Length, Word.Length) 'Select previous word
RichTextBox1.SelectionColor = Color.Black 'And set its color to black
Else 'If this is the first time, then we should start searching at position 0
startA = 0
End If
Dim startindex = RichTextBox1.Find(Word, startA.Value, RichTextBoxFinds.WholeWord)
If startindex < 0 Then 'If this is the last occurrence, exit
Exit Sub
End If
RichTextBox1.Select(startindex, Word.Length)
RichTextBox1.SelectionColor = Color.Blue
startA = startindex + Word.Length
End Sub
检查我的词典值的链接以查看格式
Check the link of my dictionary values to see the format
https://docs.google. com/document/d/1eTZaIUh7Q9zkNzjZQ-lPV9yxS5eSlNs5ht2-Pl-LS14/edit?usp = sharing
Researchpaperstobuy.com的Kelvin Nyota
Kelvin Nyota From Researchpaperstobuy.com
推荐答案
请帮助?
这篇关于访问字典的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文