将Visual Basic 6转换为VB2013“为AddressOf添加委托" [英] Visual basic 6 conversion to VB2013 "Add a delegate for AddressOf"
问题描述
我已经将一个首先使用VB2008中的转换包,从Visual Basic 6到VB2013的大型程序.下面是代码和 警告我得到.
I have converted a rather large program from Visual Basic 6 to VB2013 by first using the conversion package in VB2008. Below is the code and warning I am getting.
模块 ucString
函数 ucEqual() AsDouble
FunctionucEqual() AsDouble
ucEqual = System. Math CInt
ucEqual = System.Math.Abs(CInt(ucParamStr(1) = ucParamStr(2)))
EndFunction
; Sub ucInitStringRelational()
; 'UPGRADE_WARNING:为AddressOf ucEqual添加一个委托
'UPGRADE_WARNING: Add a delegate for AddressOf ucEqual
ucDefineFunction( 等于[a $,b $]" , AddressOf
ucDefineFunction("Equal[a$,b$]", AddressOfucEqual)
; EndSub
EndModule
我收到的错误是"; 100 addressof表达式不能转换为整数,因为integer不是委托类型"
任何见识将不胜感激
推荐答案
ucDefineFunction在哪里定义?无论如何,您需要为ucEqual函数定义一个委托,并使usDefineFunction接收该委托类型的第二个参数.例如:
Where is ucDefineFunction defined? Anyway, you need to define a delegate for the ucEqual function, and make usDefineFunction to receive its second parameter of the type of that delegate. For example:
Module ucString
Function ucEqual(ucParamStr() As String) As Double
ucEqual = System.Math.Abs(CInt(ucParamStr(1) = ucParamStr(2)))
End Function
Delegate Function ucEqualDelegate(ucParamStr() As String) As Double
Sub ucInitStringRelational()
ucDefineFunction("Equal[a
,b
",AddressOf ucEqual) 结束子 子ucDefineFunction(s作为字符串,d作为ucEqualDelegate) 结束子 终端模块
", AddressOf ucEqual) End Sub Sub ucDefineFunction(s As String, d As ucEqualDelegate) End Sub End Module
这篇关于将Visual Basic 6转换为VB2013“为AddressOf添加委托"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!