嘿,我想通過它的自動化VB6代碼轉換器將一些VB6代碼轉換爲VS 2008。大多數都做得很好,但有一些需要改進。VB6 AddressOf和VS 2008中的回調
一說觸摸起來是這段代碼:
InitializeGrCap = GrCapInitialize(AddressOf GrCapStatusEventHandler)
而且GrCapInitialize是這樣的:
Public Declare Function GrCapInitialize Lib "GrFinger.dll" Alias "[email protected]" (ByVal StatusEventHandler As Integer) As Integer
而且GrCapStatusEventHandler是:
Public Sub GrCapStatusEventHandler(ByVal pidSensor As Integer, ByVal eventRaised As Integer)
While fireStatus = True
System.Windows.Forms.Application.DoEvents()
End While
myPIdSensor = pidSensor
myEventRaised = eventRaised
fireStatus = True
While fireStatus = True
System.Windows.Forms.Application.DoEvents()
End While
End Sub
我上午不知道該如何去重新編寫,以解決問題:
錯誤44「AddressOf」表達式無法轉換爲「整型」,因爲「整數」不是委託類型。
第二個說的潤色是這一段代碼:
GrCapStartCapture(myIdSensor, AddressOf GrCapFingerEventHandler, AddressOf GrCapImageEventHandler)
周而復始,AddressOf ...是在這一個錯誤:
的GrCapFingerEventHandler:
Public Sub GrCapFingerEventHandler(ByVal pidSensor As Integer, ByVal eventRaised As Integer)
While fireFinger = True
System.Windows.Forms.Application.DoEvents()
End While
myPIdSensor = pidSensor
myEventRaised = eventRaised
fireFinger = True
While fireFinger = True
System.Windows.Forms.Application.DoEvents()
End While
End Sub
And GrCapImageEventHandler:
Public Sub GrCapImageEventHandler(ByVal pidSensor As Integer, ByVal width As Integer, ByVal height As Integer, ByVal pRawImage As Integer, ByVal res As Integer)
While fireImage = True
System.Windows.Forms.Application.DoEvents()
End While
myPIdSensor = pidSensor
myWidth = width
myHeight = height
myRes = res
myRawImage = pRawImage
fireImage = True
While fireImage = True
System.Windows.Forms.Application.DoEvents()
End While
End Sub
再次,該錯誤是:
錯誤44 'AddressOf' 表達不能被轉換爲 '整數',因爲 '整數' 不是委託類型。
任何人都可以幫助我將這2個代碼區域轉換爲.net嗎?
感謝您的回覆,JM。但是,當將其更改爲** InitializeGrCap = GrCapInitialize(新GrCapStatusCallback(AddressOf GrCapStatusEventHandler))**時,我仍然得到相同的錯誤,錯誤爲**錯誤'GrFingerSampleVB6.Callbacks.GrCapStatusCallback'類型的值無法轉換爲'Integer'** – StealthRT
然後你還沒有改變你的非託管方法的聲明,我在我的答案中特別提到了這個方法。 – jmcilhinney
對不起,錯過了那一個。 OP中陳述的第二個問題如何? – StealthRT