当此事件发生时我有扫描仪事件我有代码将扫描仪读取的内容保存到文本框。
当我跟踪它时,它工作正常,但屏幕上没有为用户显示
按钮内的此代码单击:
protected void Button1_Click(object sender, EventArgs e)
{
try
{
//Instantiate CoreScanner Class
cCoreScannerClass = new CCoreScannerClass();
//Call Open API
short[] scannerTypes = new short[1];//Scanner Types you are interested in
scannerTypes[0] = 1; // 1 for all scanner types
short numberOfScannerTypes = 1; // Size of the scannerTypes array
int status; // Extended API return code
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
// Subscribe for barcode events in cCoreScannerClass
cCoreScannerClass.BarcodeEvent += new
_ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
// Let's subscribe for events
int opcode = 1001; // Method for Subscribe events
string outXML; // XML Output
string inXML = "<inArgs>" +
"<cmdArgs>" +
"<arg-int>1</arg-int>" + // Number of events you want to subscribe
"<arg-int>1</arg-int>" + // Comma separated event IDs
"</cmdArgs>" +
"</inArgs>";
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
Console.WriteLine(outXML);
}
catch (Exception exp)
{
Console.WriteLine("Something wrong please check... " + exp.Message);
}
}
事件发生后的这段代码:
void OnBarcodeEvent(short eventType, ref string pscanData)
{
first = pscanData;
printfunction();
}
此代码在 printfunction 函数之后写入文本框:
private void printfunction()
{
int l = first.IndexOf("<datalabel>");
second = first.Substring(l + 11);
int j = second.IndexOf("</datalabel>");
second = second.Substring(0,j-1);
string newValue = second.Replace("0x", ""); ;
newValue = newValue.Replace(" ", string.Empty);
txt = GetStringFromAsciiHex(newValue);
TextBox1.Text = txt;
}
请帮我。谢谢你。