条形码扫描停止显示消息框 [英] Barcode scanning stops showing Messagebox
问题描述
我正在使用带有条形码扫描模块的c#桌面应用程序.问题是,每当我扫描条形码时,应用程序就会停止显示消息框.应用程序不会抛出任何异常,它只是执行代码.
I am working on a desktop application in c# with a barcode scanning module. The problem is that whenever I scan a barcode the application stops showing Messageboxes. Application does ot throw any exception, it just executes the code.
在扫描条形码之前,应用程序运行良好.
Application works perfectly before scanning a barcode.
我不知道为什么会这样以及如何解决.
I have no idea why is this happening and how do I solve it.
这是我的代码:
if (string.IsNullOrEmpty(BarcodeScan) && e.KeyChar.ToString() == "*")
BarcodeScan = e.KeyChar.ToString();
else if (Regex.IsMatch(BarcodeScan + e.KeyChar.ToString(), @"^[*]\d+$"))
BarcodeScan += e.KeyChar.ToString();
else if (Regex.IsMatch(BarcodeScan + e.KeyChar.ToString(), @"^[*]\d+[*]$"))
{
BarcodeScan += e.KeyChar.ToString();
ArticalID = BarcodeScan.Substring(1, BarcodeScan.Length - 2);
//Code to find article in DB
ArticalID = string.Empty;
BarcodeScan = string.Empty;
}
else
{
if (BarcodeScan.StartsWith("*"))
{
BarcodeScan = string.Empty;
}
}
推荐答案
据我所知,您的问题:条形码扫描器发送的扫描数字/字符大多以"Enter"结尾.输入的内容可能会通过调用默认按钮关闭您的MessageBox.
As far as I understand your question: a barcode scanner sends the scanned numbers / characters mostly with an "Enter" at the end. Maybe that enter closes your MessageBox by invoking the default button.
这篇关于条形码扫描停止显示消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!