试图“显示”控制文本框中的字符 [英] Trying to "display" control characters in a text box

查看:70
本文介绍了试图“显示”控制文本框中的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用键盘楔的条形码扫描仪。程序,以便它扫描的

数据就像在键盘上输入一样。我正在尝试

让条形码中的数据显示在文本框中。我知道

数据中嵌入了某些控制字符,我想在文本框中显示替换为
,例如我要替换

ASCII字符04,字符串为< EOT>。我曾尝试在TextChanged事件中做一个简单的

替换,但看起来文本框控件

在控制字符进入时将其删除。我也试过捕捉

" keystrokes"使用KeyUp事件,但似乎已经用某些控制字符

并且添加了其他字符来完成

某事(并且我无法弄清楚是什么)不在数据中。有没有人有关于如何实现这一目标的任何

建议?我知道在条形码中编码的数据是多少,而且我可以验证扫描仪正在读它

正确 - 我只是不能把它变成VB .Net文本框正确。


TIA

Ron L

I have a barcode scanner which uses a "keyboard wedge" program so that the
data it scans comes through as if it was typed on a keyboard. I am trying
to have the data in the barcode be displayed in a text box. I know that
there are certain control characters embedded in the data that I want to
display substitutions for in the text box, for instance I want to replace
ASCII character 04 with the string "<EOT>". I have tried doing a simple
replace in the TextChanged event, but it appears that the Textbox Control
strips out the control characters as they come in. I also tried catching
the "keystrokes" using the KeyUp event, but that seems to have done
something (and I can''t figure out what) with some of the control characters
and added other characters that are not in the data. Does anyone have any
suggestions as to how I can accomplish this? I know what the data encoded
in the barcode is, and I can verify that the scanner is reading it
properly - I just can''t get it into a VB.Net text box properly.

TIA
Ron L

推荐答案

尝试创建一个简单的控制台应用程序并读入键盘缓冲区,

这样可以更容易''替换''不可打印的字符...


Ron L写道:
Try creating a simple Console Application and read in the keyboard buffer,
this should make it easier to ''Replace'' non printable characters...

"Ron L" wrote:
我有一个使用键盘楔的条形码扫描仪。程序,以便它扫描的数据就像在键盘上输入一样。我正在尝试将条形码中的数据显示在文本框中。我知道
数据中嵌入了某些控制字符,我想在文本框中显示替换,例如我想用字符串替换ASCII字符04。 < EOT>" ;.我曾尝试在TextChanged事件中做一个简单的替换,但看起来文本框控件会在控制字符进入时删除它。我还尝试捕获击键。使用KeyUp事件,但似乎已经完成了一些(并且我不知道是什么)一些控制字符
并添加了其他不在数据中的字符。有没有人对我如何做到这一点有任何建议?我知道条形码中编码的数据是什么,我可以验证扫描仪是否正确读取它 - 我无法正确地将它放入VB.Net文本框中。 />
TIA
Ron L
I have a barcode scanner which uses a "keyboard wedge" program so that the
data it scans comes through as if it was typed on a keyboard. I am trying
to have the data in the barcode be displayed in a text box. I know that
there are certain control characters embedded in the data that I want to
display substitutions for in the text box, for instance I want to replace
ASCII character 04 with the string "<EOT>". I have tried doing a simple
replace in the TextChanged event, but it appears that the Textbox Control
strips out the control characters as they come in. I also tried catching
the "keystrokes" using the KeyUp event, but that seems to have done
something (and I can''t figure out what) with some of the control characters
and added other characters that are not in the data. Does anyone have any
suggestions as to how I can accomplish this? I know what the data encoded
in the barcode is, and I can verify that the scanner is reading it
properly - I just can''t get it into a VB.Net text box properly.

TIA
Ron L



Ron,


条形码扫描器如何输入此ASCII(04)?是按惯例模拟

按Ctrl + D?如果确实如此,TextBox将它们剥离出来也就不足为奇了 - 对于TextBox,Ctrl + D没有定义快捷键,所以它只是跳过它

(可能会产生一些根据声音方案发出哔哔声)。

如果你的条形码扫描器试图以这种方式发送ASCII(03),那么TextBox将进行复制操作。

- -


Stoitcho Goutsev(100)

" Ron L" < RO ** @ bogus.Address.com>在留言中写道

新闻:eB ************** @ TK2MSFTNGP09.phx.gbl ...
Ron,

How the barcode scanner enters this ASCII (04)? Is it actully simulates
pressing Ctrl+D? If it does it is no surprise that the TextBox strips them
out - for the TextBox Ctrl+D is not defined shortcut so it just skips it
(probably it produces some beeping sound depending on the sound scheme). The
same way the TextBox will perfome copy operation if your barcode scanner is
trying to send ASCII(03) in this way.
--

Stoitcho Goutsev (100)

"Ron L" <ro**@bogus.Address.com> wrote in message
news:eB**************@TK2MSFTNGP09.phx.gbl...
我有一个条码扫描器它使用键盘楔形和键盘楔形。程序,以便它扫描的数据就像在键盘上输入一样。我正在尝试将条形码中的数据显示在文本框中。我知道
数据中嵌入了某些控制字符,我想在文本框中显示替换,例如我想用字符串替换ASCII字符04。 < EOT>" ;.我曾尝试在TextChanged事件中做一个简单的替换,但看起来文本框控件会在控制字符进入时删除它。我还尝试捕获击键。使用KeyUp事件,但似乎已经完成了一些(并且我不知道是什么)一些控制字符
并添加了其他不在数据中的字符。有没有人对我如何做到这一点有任何建议?我知道条形码中编码的数据是什么,我可以验证扫描仪是否正确读取它 - 我无法正确地将它放入VB.Net文本框中。 />
TIA
Ron L
I have a barcode scanner which uses a "keyboard wedge" program so that the
data it scans comes through as if it was typed on a keyboard. I am trying
to have the data in the barcode be displayed in a text box. I know that
there are certain control characters embedded in the data that I want to
display substitutions for in the text box, for instance I want to replace
ASCII character 04 with the string "<EOT>". I have tried doing a simple
replace in the TextChanged event, but it appears that the Textbox Control
strips out the control characters as they come in. I also tried catching
the "keystrokes" using the KeyUp event, but that seems to have done
something (and I can''t figure out what) with some of the control characters
and added other characters that are not in the data. Does anyone have any
suggestions as to how I can accomplish this? I know what the data encoded
in the barcode is, and I can verify that the scanner is reading it
properly - I just can''t get it into a VB.Net text box properly.

TIA
Ron L



你好,Ron,


您是否可以先将扫描输入移动到字符串变量

。如果是这样,那么你可以在将它移动到TextBox之前替换

字符串中的控制字符。类似于:


TextBox1.text = ReplaceCCs(strInput)


其中ReplaceCCs是一个函数,在VB中类似于:


私有函数ReplaceCCs(ByVal输入为字符串)字符串


''用适当的替换字符串填写TBC:

Dim straSubs()As String = {"< Nul>","< TBC>","< TBC>","< TBC>",_

"< TBC>","< TBC>","< TBC>","< TBC>",_

"< TBC>","< Tab>","< LF>","< VT>",_

"< ; FF>","< CR>","< TBC>","< TBC>",_

"< TBC>" ,< TBC>""< TBC>","< TBC>",_

"< TBC>","< TBC>","< TBC>""< T BC>",_

"< TBC>","< TBC>","< TBC>","< TBC>", _

"< TBC>","< TBC>","< TBC>","< TBC>"}

Dim strOut As String =输入

对于intChar As Integer = 0到31

strOut = strOut.Replace(Chr(intChar),straSubs(intChar))

下一个intChar


strOut = strOut.Replace(Chr(127),"< Del>")


返回strOut


结束功能


我有点懒,没有填写所有适当的替换

代码 - 我可以轻松记住几个。


干杯,

兰迪

Ron L写道:
Hello, Ron,

Is it possible that you can move the scanned input to a String variable
first. If so then you can just replace the control characters in the
string before you move it to the TextBox. Something like:

TextBox1.text = ReplaceCCs(strInput)

where ReplaceCCs is a function, in VB something like:

Private Function ReplaceCCs(ByVal Input As String) As String

'' Fill in the "TBC"s with appropriate replacement strings:
Dim straSubs() As String = {"<Nul>", "<TBC>", "<TBC>", "<TBC>", _
"<TBC>", "<TBC>", "<TBC>", "<TBC>", _
"<TBC>", "<Tab>", "<LF>", "<VT>", _
"<FF>", "<CR>", "<TBC>", "<TBC>", _
"<TBC>", "<TBC>", "<TBC>", "<TBC>", _
"<TBC>", "<TBC>", "<TBC>", "<TBC>", _
"<TBC>", "<TBC>", "<TBC>", "<TBC>", _
"<TBC>", "<TBC>", "<TBC>", "<TBC>"}
Dim strOut As String = Input
For intChar As Integer = 0 To 31
strOut = strOut.Replace(Chr(intChar), straSubs(intChar))
Next intChar

strOut = strOut.Replace(Chr(127), "<Del>")

Return strOut

End Function

I''ve been a bit lazy, and not filled in all the appropriate substitution
codes -- just a few I could easily remember.

Cheers,
Randy
Ron L wrote:
我有一个使用键盘楔的条形码扫描仪。程序,以便它扫描的数据就像在键盘上输入一样。我正在尝试将条形码中的数据显示在文本框中。我知道
数据中嵌入了某些控制字符,我想在文本框中显示替换,例如我想用字符串替换ASCII字符04。 < EOT>" ;.我曾尝试在TextChanged事件中做一个简单的替换,但看起来文本框控件会在控制字符进入时删除它。我还尝试捕获击键。使用KeyUp事件,但似乎已经完成了一些(并且我不知道是什么)一些控制字符
并添加了其他不在数据中的字符。有没有人对我如何做到这一点有任何建议?我知道条形码中编码的数据是什么,我可以验证扫描仪是否正确读取它 - 我无法正确地将它放入VB.Net文本框中。 />
TIA
Ron L
I have a barcode scanner which uses a "keyboard wedge" program so that the
data it scans comes through as if it was typed on a keyboard. I am trying
to have the data in the barcode be displayed in a text box. I know that
there are certain control characters embedded in the data that I want to
display substitutions for in the text box, for instance I want to replace
ASCII character 04 with the string "<EOT>". I have tried doing a simple
replace in the TextChanged event, but it appears that the Textbox Control
strips out the control characters as they come in. I also tried catching
the "keystrokes" using the KeyUp event, but that seems to have done
something (and I can''t figure out what) with some of the control characters
and added other characters that are not in the data. Does anyone have any
suggestions as to how I can accomplish this? I know what the data encoded
in the barcode is, and I can verify that the scanner is reading it
properly - I just can''t get it into a VB.Net text box properly.

TIA
Ron L



这篇关于试图“显示”控制文本框中的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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