以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  关于用扫描枪扫码  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=86394)

--  作者:czy66ds
--  发布时间:2016/6/16 15:16:00
--  关于用扫描枪扫码
窗口1有一控件TextBox1,是否有办法实现如下效果:
敲击键盘不能输入字符但可以用扫描枪扫码的方式输入信息?

--  作者:大红袍
--  发布时间:2016/6/16 16:37:00
--  

比如,keypress事件,写代码

 

static ptime As Date = Nothing

Dim sp As TimeSpan = Date.now - ptime
ptime = Date.now
If sp.TotalMilliseconds > 50  Then
    e.Sender.text = ""
    e.Cancel = True
End If


--  作者:方丈
--  发布时间:2017/3/16 19:03:00
--  
用了以上代码,扫描后,本来应该是20160001,TextBox1只输入了0160001,少了第一位“2”,不知何故?
--  作者:方丈
--  发布时间:2017/3/16 19:21:00
--  
用了以上代码,扫描后,本来应该是20160001,TextBox1只输入了0160001,少了第一位“2”,不知何故?
--  作者:有点色
--  发布时间:2017/3/16 19:23:00
--  

处理一下

 

static ptime As Date = Nothing

Dim sp As TimeSpan = Date.now - ptime
ptime = Date.now
If sp.TotalMilliseconds > 50 AndAlso e.Sender.Text.Length > 0 Then
    e.Sender.text = ""
    e.Cancel = True
End If