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