如何检测条形码扫描器是否使用“标签”进行格式化。后缀 [英] How to detect whether barcode scanner is formatted with a "tab" suffix

查看:77
本文介绍了如何检测条形码扫描器是否使用“标签”进行格式化。后缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VB.net程序,其文本框可通过条形码扫描程序填充。为了使事情正常工作,条形码扫描仪需要使用Tab后缀进行格式化。每隔一段时间,条形码扫描仪就会被替换,最终会被错误的后缀格式化。通常情况下,他们会使用Enter与Tab进行格式化。这有时会导致问题,因为如果按钮在条形码后有焦点,则输入将单击按钮。为了解决这个问题,我正在尝试编写代码以验证条形码扫描器是否使用Tab格式化。我以为我可以使用keydown事件,但它没有检测条形码阅读器中的标签。我确保将文本框的AcceptsTab属性设置为True,并且还将multiline属性设置为true。如果我实际上是通过键盘按Tab键,它会识别标签但不能识别条形码阅读器。我继续重新格式化条形码阅读器以添加标签后缀,当我将条形码扫描到NotePad时,我可以看到标签。关于为什么这不起作用的任何想法?重要的是,我使用带USB输入的霍尼韦尔3800G扫描仪。



我尝试过:



I have a VB.net program that has textboxes that get populated via a barcode scanner. For things to work properly, the barcode scanner needs to be formatted with a "Tab" suffix. Every once in a while, the barcode scanners get replaced and end up getting formatted with the wrong suffix. Usually what happens is they get formatted with an "Enter" vs a "Tab". This can sometimes cause issues because if a button has focus after the barcode, the enter will "click" the button. To address this issue, I am trying to write code to validate the barcode scanner is formatted with a "Tab". I thought I could use the keydown event but it is not detecting the tab from the barcode reader. I made sure I set the AcceptsTab property of the textbox to True and I also set the multiline property to true. If I actually press the tab key via the keyboard, it recognizes the tab but not from the barcode reader. I went ahead and reformatted the barcode reader to add the tab suffix and I can see the tab when I scan the barcode into NotePad. Any ideas on why this is not working? It is matters, I am using a Honeywell 3800G scanner with USB input.

What I have tried:

Private Sub TxtSequenceBarcode_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TxtSequenceBarcode.KeyDown

        Debug.WriteLine("KeyDown = " & e.KeyCode)

        If e.KeyCode = Keys.Tab Then
            Debug.WriteLine("Tab Found via KeyDown")
        End If
    End Sub

推荐答案

问题是,如果未设置条形码扫描器,它将不会为您提供TAB在所有 - 它只会给你扫描的数字,没有前缀或后缀信息。并且你可以告诉你是否输入或扫描了数字信息,因为Windows没有保留这类信息。



检测缺少数据的唯一方法TAB是在您收到实际数据时设置计时器,并清除您是否收到TAB键。如果计时器在合理的时间(可能是几秒钟)之后到期,那么你没有得到TAB。
The problem is that if the barcode scanner isn't set, it won't give you a TAB at all - it will just give you the numbers it scans, with no prefix or suffix info. And you can;t tell if that numeric infor was typed or scanned as Windows doesn't keep that kind of information.

The only way to detect the absence of a TAB is to set up a timer when you receive the actual data and clear if it you do receive a TAB key. If the timer expires after a "reasonable time (a couple of seconds maybe) then you didn't get a TAB.


这篇关于如何检测条形码扫描器是否使用“标签”进行格式化。后缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆