查找/替换搜索的vb.net重载解析失败

查找/替换搜索的vb.net重载解析失败,vb.net,function,replace,find,Vb.net,Function,Replace,Find,以上产生的误差为 重载解析失败,因为在没有缩小转换的情况下无法调用可访问的'Find': Public Function Find(characterSet() As Char, start As Integer, end As Integer) As Integer: 参数匹配参数'characterSet'变窄 从“字符串”到“字符的一维数组” Public Function Find(characterSet() As Char, start As Integer

以上产生的误差为

重载解析失败,因为在没有缩小转换的情况下无法调用可访问的
'Find'


Public Function Find(characterSet() As Char, 
    start As Integer, end As Integer) As Integer:
参数匹配参数
'characterSet'
变窄 从
“字符串”
“字符的一维数组”


Public Function Find(characterSet() As Char, 
    start As Integer, end As Integer) As Integer:
参数匹配参数
'options'
'Integer'
缩小到
“System.Windows.Forms.RichTextBoxFinds”

仅当将第二个或第三个值更改为
0
以外的值时,如果更改替换字符串值,则不会发生错误

为什么这里不能使用标准整数?这个错误到底意味着什么?有人能给我指一些在vb.net(2010)中处理重载函数的文档吗

我希望这个问题足够集中。。。我只是对这件事很困惑


感谢您的帮助-EB

您的函数调用与任何重载都不完全匹配。不过,VB很友好,找到了两个可能的匹配项,如果您提供的参数被强制转换为不同的类型,这两个匹配项将起作用

您可能希望使用
字符串
参数重载。所以你应该写

Public Function Find(str As String, start As Integer, 
    options As System.Windows.Forms.RichTextBoxFinds) As Integer: 
RichTextBoxFinds.WholeWord
恰好有数值
2
这一事实并不是使用该值而不是枚举成员名称的原因

这也将有助于:

RichTextBox1.Find(lowstring, 0, RichTextBoxFinds.WholeWord)

但是这很愚蠢。

您的函数调用与任何重载都不完全匹配。不过,VB很友好,找到了两个可能的匹配项,如果您提供的参数被强制转换为不同的类型,这两个匹配项将起作用

您可能希望使用
字符串
参数重载。所以你应该写

Public Function Find(str As String, start As Integer, 
    options As System.Windows.Forms.RichTextBoxFinds) As Integer: 
RichTextBoxFinds.WholeWord
恰好有数值
2
这一事实并不是使用该值而不是枚举成员名称的原因

这也将有助于:

RichTextBox1.Find(lowstring, 0, RichTextBoxFinds.WholeWord)
但是它很愚蠢。

正如您所看到的,它有7个重载。 您正在使用3个参数和两个整数调用的参数以
Char[]
作为第一个参数,而不是
字符串

当您希望从字符列表中查找字符的第一个实例时,将使用此重载

我假设您希望在给定范围内找到
字符串的位置。然后您需要使用此重载:

例如:

RichTextBox1.Find(lowstring, 0, CType(2, RichTextBoxFinds))
' Obtain the location of the search string in RichTextView'
Dim index = RichTextView.Find(lowstring, 0, 2, RichTextBoxFinds.WholeWord)
请注意,可以按位组合不同的值

例如:

RichTextBox1.Find(lowstring, 0, CType(2, RichTextBoxFinds))
' Obtain the location of the search string in RichTextView'
Dim index = RichTextView.Find(lowstring, 0, 2, RichTextBoxFinds.WholeWord)
如您所见,有7个重载。 您正在使用3个参数和两个整数调用的参数以
Char[]
作为第一个参数,而不是
字符串

当您希望从字符列表中查找字符的第一个实例时,将使用此重载

我假设您希望在给定范围内找到
字符串的位置。然后您需要使用此重载:

例如:

RichTextBox1.Find(lowstring, 0, CType(2, RichTextBoxFinds))
' Obtain the location of the search string in RichTextView'
Dim index = RichTextView.Find(lowstring, 0, 2, RichTextBoxFinds.WholeWord)
请注意,可以按位组合不同的值

例如:

RichTextBox1.Find(lowstring, 0, CType(2, RichTextBoxFinds))
' Obtain the location of the search string in RichTextView'
Dim index = RichTextView.Find(lowstring, 0, 2, RichTextBoxFinds.WholeWord)