需要在方法和委托间进行无法进行的转换时,将出现此错误。 错误的原因可能是在参数之间进行转换,或者(当方法和委托是函数时)在返回值中进行转换。
以下代码阐释了这些失败的转换。 委托是 FunDel。
Delegate Function FunDel(ByVal i As Integer, ByVal d As Double) As Integer
以下每个函数都不同于 FunDel ,这种不同会导致此错误。
Function ExampleMethod1(ByVal m As Integer, ByVal aDate As Date) As Integer
End Function
Function ExampleMethod2(ByVal m As Integer, ByVal aDouble As Double) As Date
End Function
下面的每一个赋值语句都会导致此错误。
Sub Main()
' The second parameters of FunDel and ExampleMethod1, Double and Date,
' are not compatible.
'Dim d1 As FunDel = AddressOf ExampleMethod1
' The return types of FunDel and ExampleMethod2, Integer and Date,
' are not compatible.
'Dim d2 As FunDel = AddressOf ExampleMethod2
End Sub
错误 ID: BC31143
更正此错误
- 检查相应参数,如果这些参数存在,则返回类型以确定不兼容的参数对。