1
嘗試將讀卡器從VB6改編爲vb.net。轉換後,我得到這個錯誤:將代碼錯誤從VB6轉換爲vb.net
'AddressOf' expression cannot be converted to 'Integer' because 'Integer' is not a delegate type
這裏是我使用的代碼:
Public Sub SetupCallBacks()
'UPGRADE_WARNING: Add a delegate for AddressOf OnEventDeviceStateChanged Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="E9E157F7-EF0C-4016-87B7-7D7FBBC6EE08"'
Call MTUSCRADeviceStateChangedNotify(AddressOf OnEventDeviceStateChanged)
'UPGRADE_WARNING: Add a delegate for AddressOf OnEventCardDataStateChanged Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="E9E157F7-EF0C-4016-87B7-7D7FBBC6EE08"'
Call MTUSCRACardDataStateChangedNotify(AddressOf OnEventCardDataStateChanged)
End Sub
Public Sub OnEventDeviceStateChanged(ByVal parm As Integer)
If (gbEvents) Then
If (glDeviceState <> parm) Then
glDeviceState = parm
End If
Select Case glDeviceState
Case MTSCRA_STATE_DISCONNECTED
SetStatus(("OnEventDeviceStateChanged:Disconnected"))
Case MTSCRA_STATE_CONNECTED
SetStatus(("OnEventDeviceStateChanged:Connected"))
Case MTSCRA_STATE_ERROR
SetStatus(("OnEventDeviceStateChanged:Error"))
End Select
End If
End Sub
據我知道我需要做什麼代表,但我不知道如何去做吧。
感謝您的答覆,這確實解決了這個問題,但我的低調實習生並沒有意識到使用這種方法來讀取HID需要一個.dll文件,它不會被用在它將屬於的功能中...... – user2620509
@ user2620509是外部DLL中的「MTUSCRACardDataStateChangedNotify」?即它是由'Declare'語句定義的嗎?在這種情況下,我不認爲這個答案適用。 – MarkJ