对此的任何帮助都非常感谢 -
我在 VB .NET 中触发 BarcodeEvent 时遇到问题。扫描仪处于 USB(IBM 手持)模式,一切都可以与 SDK 附带的 C# 示例应用程序一起正常工作。此外,我可以在 VB .net 中使扫描仪发出哔哔声,因此驱动程序工作正常。我可能搞砸了将此 C# 代码转换为 VB
cCoreScannerClass.BarcodeEvent += new
_ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
void OnBarcodeEvent(short eventType, ref string pscanData)
{
string barcode = pscanData;
this.Invoke((MethodInvoker)delegate { textBox1.Text = barcode; });
}
-- 这是我的代码:--------
Imports CoreScanner
Imports System.Collections.Generic
Imports System.Text
Public Class Form1
Public WithEvents cCoreScannerClass As CCoreScannerClass
Sub Main()
cCoreScannerClass = New CCoreScannerClass
Dim scannertype(1) As Short
scannertype(0) = 1
Dim numberOfScannerTypes As Short
numberOfScannerTypes = 1
Dim status As Integer
cCoreScannerClass.Open(0, scannertype, numberOfScannerTypes, status)
AddHandler cCoreScannerClass.BarcodeEvent, AddressOf OnBarcodeEvent
Dim opcode As Integer = 1001
Dim outXML As String
Dim inXML = "<inArgs>" +
"<cmdArgs>" +
"<arg-int>1</arg-int>" +
"<arg-int>1</arg-int>" +
"</cmdArgs>" +
"</inArgs>"
cCoreScannerClass.ExecCommand(opcode, inXML, outXML, status)
End Sub
Public Sub OnBarcodeEvent(eventType As Short, ByRef pscanData As String) Handles cCoreScannerClass.BarcodeEvent
MsgBox("Success!")
End Sub