473,382 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Trying to "display" control characters in a text box

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
Apr 3 '06 #1
11 11059
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:
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

Apr 3 '06 #2
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...
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

Apr 3 '06 #3
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:
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

Apr 4 '06 #4
Randy

Thanks for the response. My problem is that the scanner acts like a
keyboard, so I'm not sure how to get the original informaion into a string
in the first place. I have tried catching the key up event, but I haven't
figured out what to place in the string to get the control characters into
the string. I have printed out the key values, and can't find a correlation
between the key value or key code and the control character I am expecting
to see.

Ron L
"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44***********************@news.wanadoo.nl...
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:
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


Apr 4 '06 #5
Hello, Ron,

I've never worked with a scanner, so please excuse my ignorance. What
kind of control is it that receives the input? (I had assumed it would
be something akin to a TextBox and you could just use the Text property
after completion of the input.)

But when you say that you're catching the key-up event, perhaps the
processing required is more sophisticated than I realized.

Can you provide any additional information, or perhaps an example of the
code that you are trying to make work?

Cheers,
Randy
Ron L wrote:
Randy

Thanks for the response. My problem is that the scanner acts like a
keyboard, so I'm not sure how to get the original informaion into a string
in the first place. I have tried catching the key up event, but I haven't
figured out what to place in the string to get the control characters into
the string. I have printed out the key values, and can't find a correlation
between the key value or key code and the control character I am expecting
to see.

Ron L

Apr 5 '06 #6
Randy

I am using a text box control, but apparently there is logic in that control
that strips out most of the control characters (ASCII values < 32) before
entering them into the Text property. I had hoped that by catching the
Key-up event I could somehow "bypass" the code that removes the control
characters.

As far as the scanner is concerned, it is simply acting as if it is a
keyboard and is sending on the characters that were "typed".

Thanks,

Ron L

"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44**********************@news.wanadoo.nl...
Hello, Ron,

I've never worked with a scanner, so please excuse my ignorance. What
kind of control is it that receives the input? (I had assumed it would be
something akin to a TextBox and you could just use the Text property after
completion of the input.)

But when you say that you're catching the key-up event, perhaps the
processing required is more sophisticated than I realized.

Can you provide any additional information, or perhaps an example of the
code that you are trying to make work?

Cheers,
Randy
Ron L wrote:
Randy

Thanks for the response. My problem is that the scanner acts like a
keyboard, so I'm not sure how to get the original informaion into a
string in the first place. I have tried catching the key up event, but I
haven't figured out what to place in the string to get the control
characters into the string. I have printed out the key values, and can't
find a correlation between the key value or key code and the control
character I am expecting to see.

Ron L

Apr 5 '06 #7
Hello, Ron,

I'm not aware of any logic that strips out control characters from a
TextBox. For example, when I type into a multiline textBox using a
keyboard I can easily insert new line characters (<CR><LF>) by typing
<CNTL><Enter>, or other control characters by using Copy/Paste. These
are returned in the Text property.

Also, almost all keystrokes (including the Control keys) are available
via the Key-up events. (As I recall there are a few "navigation" keys
that do not normally appear there, but I think that even these can be
persuaded to appear with a little extra work.)

I wonder if there is something between the scanner driver and the
TextBox that is swallowing the characters you are expecting to see. Do
you have KeyPreview enabled for the Form that contains the TextBox? Or
is there possibly something more sophisticated such as an override of
WndProc interfering?

Anyway, I'm rather doubtful that the problem is with the TextBox.

Cheers,
Randy
Ron L wrote:
Randy

I am using a text box control, but apparently there is logic in that control
that strips out most of the control characters (ASCII values < 32) before
entering them into the Text property. I had hoped that by catching the
Key-up event I could somehow "bypass" the code that removes the control
characters.

As far as the scanner is concerned, it is simply acting as if it is a
keyboard and is sending on the characters that were "typed".

Thanks,

Ron L

"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44**********************@news.wanadoo.nl...
Hello, Ron,

I've never worked with a scanner, so please excuse my ignorance. What
kind of control is it that receives the input? (I had assumed it would be
something akin to a TextBox and you could just use the Text property after
completion of the input.)

But when you say that you're catching the key-up event, perhaps the
processing required is more sophisticated than I realized.

Can you provide any additional information, or perhaps an example of the
code that you are trying to make work?

Cheers,
Randy
Ron L wrote:
Randy

Thanks for the response. My problem is that the scanner acts like a
keyboard, so I'm not sure how to get the original informaion into a
string in the first place. I have tried catching the key up event, but I
haven't figured out what to place in the string to get the control
characters into the string. I have printed out the key values, and can't
find a correlation between the key value or key code and the control
character I am expecting to see.

Ron L


Apr 5 '06 #8
Randy

Sorry, I should have been more specific. The text box removes *some* of the
control characters. My string has the RS (ASCII 30), GS (ASCII 29), and EOT
(ASCII 4) embedded in it. These are commonly represented as ctl-^, ctl-],
and ctl-D, respectively. If I open a command prompt and scan the label I
see all the expected control characters on the entered line, but in the text
box the GS and EOT have been stripped out! Given that, I am reasonably that
either the TextBox or some portion of the windows key event handling is
removing the GS and EOT characters from my input string.

Arrggghhhh!
Ron L
"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44***********************@news.wanadoo.nl...
Hello, Ron,

I'm not aware of any logic that strips out control characters from a
TextBox. For example, when I type into a multiline textBox using a
keyboard I can easily insert new line characters (<CR><LF>) by typing
<CNTL><Enter>, or other control characters by using Copy/Paste. These are
returned in the Text property.

Also, almost all keystrokes (including the Control keys) are available via
the Key-up events. (As I recall there are a few "navigation" keys that do
not normally appear there, but I think that even these can be persuaded to
appear with a little extra work.)

I wonder if there is something between the scanner driver and the TextBox
that is swallowing the characters you are expecting to see. Do you have
KeyPreview enabled for the Form that contains the TextBox? Or is there
possibly something more sophisticated such as an override of WndProc
interfering?

Anyway, I'm rather doubtful that the problem is with the TextBox.

Cheers,
Randy
Ron L wrote:
Randy

I am using a text box control, but apparently there is logic in that
control that strips out most of the control characters (ASCII values <
32) before entering them into the Text property. I had hoped that by
catching the Key-up event I could somehow "bypass" the code that removes
the control characters.

As far as the scanner is concerned, it is simply acting as if it is a
keyboard and is sending on the characters that were "typed".

Thanks,

Ron L

"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44**********************@news.wanadoo.nl...
Hello, Ron,

I've never worked with a scanner, so please excuse my ignorance. What
kind of control is it that receives the input? (I had assumed it would
be something akin to a TextBox and you could just use the Text property
after completion of the input.)

But when you say that you're catching the key-up event, perhaps the
processing required is more sophisticated than I realized.

Can you provide any additional information, or perhaps an example of the
code that you are trying to make work?

Cheers,
Randy
Ron L wrote:

Randy

Thanks for the response. My problem is that the scanner acts like a
keyboard, so I'm not sure how to get the original informaion into a
string in the first place. I have tried catching the key up event, but
I haven't figured out what to place in the string to get the control
characters into the string. I have printed out the key values, and
can't find a correlation between the key value or key code and the
control character I am expecting to see.

Ron L



Apr 6 '06 #9
Hello, Ron,

Perhaps these keys are being swallowed by some preprocessing on the
form. Have a look at the help for the "IsInputKey" (and possibly the
"IsInputChar") function. Perhaps they will help you out. I have
previously used the former in order to "capture" some of the navigation
keys. Here is an example of IsInputKey:

Protected Overrides _
Function IsInputKey(ByVal keyData As Keys) As Boolean
' Inhibit pre-processing for selected "special" keys
' that are handled directly by the control.
Select Case keyData
Case Keys.Down, Keys.Left, Keys.Right, Keys.Up
Return (Me.UserMode = aenmUserMode.Design)
Case Else
Return False
End Select

End Function

Cheers,
Randy
Ron L wrote:
Randy

Sorry, I should have been more specific. The text box removes *some* of the
control characters. My string has the RS (ASCII 30), GS (ASCII 29), and EOT
(ASCII 4) embedded in it. These are commonly represented as ctl-^, ctl-],
and ctl-D, respectively. If I open a command prompt and scan the label I
see all the expected control characters on the entered line, but in the text
box the GS and EOT have been stripped out! Given that, I am reasonably that
either the TextBox or some portion of the windows key event handling is
removing the GS and EOT characters from my input string.

Arrggghhhh!
Ron L
"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44***********************@news.wanadoo.nl...
Hello, Ron,

I'm not aware of any logic that strips out control characters from a
TextBox. For example, when I type into a multiline textBox using a
keyboard I can easily insert new line characters (<CR><LF>) by typing
<CNTL><Enter>, or other control characters by using Copy/Paste. These are
returned in the Text property.

Also, almost all keystrokes (including the Control keys) are available via
the Key-up events. (As I recall there are a few "navigation" keys that do
not normally appear there, but I think that even these can be persuaded to
appear with a little extra work.)

I wonder if there is something between the scanner driver and the TextBox
that is swallowing the characters you are expecting to see. Do you have
KeyPreview enabled for the Form that contains the TextBox? Or is there
possibly something more sophisticated such as an override of WndProc
interfering?

Anyway, I'm rather doubtful that the problem is with the TextBox.

Cheers,
Randy
Ron L wrote:

Randy

I am using a text box control, but apparently there is logic in that
control that strips out most of the control characters (ASCII values <
32) before entering them into the Text property. I had hoped that by
catching the Key-up event I could somehow "bypass" the code that removes
the control characters.

As far as the scanner is concerned, it is simply acting as if it is a
keyboard and is sending on the characters that were "typed".

Thanks,

Ron L

"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44**********************@news.wanadoo.nl.. .
Hello, Ron,

I've never worked with a scanner, so please excuse my ignorance. What
kind of control is it that receives the input? (I had assumed it would
be something akin to a TextBox and you could just use the Text property
after completion of the input.)

But when you say that you're catching the key-up event, perhaps the
processing required is more sophisticated than I realized.

Can you provide any additional information, or perhaps an example of the
code that you are trying to make work?

Cheers,
Randy
Ron L wrote:
>Randy
>
>Thanks for the response. My problem is that the scanner acts like a
>keyboard, so I'm not sure how to get the original informaion into a
>string in the first place. I have tried catching the key up event, but
>I haven't figured out what to place in the string to get the control
>characters into the string. I have printed out the key values, and
>can't find a correlation between the key value or key code and the
>control character I am expecting to see.
>
>Ron L

Apr 6 '06 #10
Randy

Thanks, that definitely was a step in the right direction. I put in both
the IsInputKey and IsInputChar routines (included below) and I now get the
RS character in the final output. I still don't get the GS and EOT
characters, though, even though they are handled in the IsInputChar routine
(I see the debug printouts). I suspect that this is due to a problem with
how I am handling them in the IsInputKey routine. Do you have any other
suggestions?

Thanks again,
Ron L
'********************* ControlCharactersTextBox Class
********************************
Imports System.Windows.Forms

Public Class CtlCharTextBox
Inherits System.Windows.Forms.TextBox

Protected Overrides Function IsInputKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If (keyData And Keys.Control) And (keyData And Keys.D) Then
Debug.WriteLine("IsInputKey: <EOT>")
Return True
ElseIf (keyData And Keys.Control) And (keyData And
Keys.OemCloseBrackets) Then
Debug.WriteLine("IsInputKey: <GS>")
Return True
ElseIf (keyData And Keys.Control) And (keyData And Keys.D6) Then
Debug.WriteLine("IsInputKey: <RS>")
Return True
Else
Return MyBase.IsInputKey(keyData)
End If
End Function

Protected Overrides Function IsInputChar(ByVal charCode As Char) As
Boolean
'Return MyBase.IsInputChar(charCode)
Select Case Asc(charCode)
Case 4 ' EOT character
'Debug.Write(Asc(charCode) & ", " & "<EOT> ")
Return True
Case 29 ' GS character
'Debug.Write(Asc(charCode) & ", " & "<GS> ")
Return True
Case 30 ' RS character
'Debug.Write(Asc(charCode) & ", " & "<RS> ")
Return True
Case Else
'Debug.Write(Asc(charCode) & ", " & charCode & " ")
Return MyBase.IsInputChar(charCode)
End Select
End Function
End Class
"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44**********************@news.wanadoo.nl...
Hello, Ron,

Perhaps these keys are being swallowed by some preprocessing on the form.
Have a look at the help for the "IsInputKey" (and possibly the
"IsInputChar") function. Perhaps they will help you out. I have
previously used the former in order to "capture" some of the navigation
keys. Here is an example of IsInputKey:

Protected Overrides _
Function IsInputKey(ByVal keyData As Keys) As Boolean
' Inhibit pre-processing for selected "special" keys
' that are handled directly by the control.
Select Case keyData
Case Keys.Down, Keys.Left, Keys.Right, Keys.Up
Return (Me.UserMode = aenmUserMode.Design)
Case Else
Return False
End Select

End Function

Cheers,
Randy
Ron L wrote:
Randy

Sorry, I should have been more specific. The text box removes *some* of
the control characters. My string has the RS (ASCII 30), GS (ASCII 29),
and EOT (ASCII 4) embedded in it. These are commonly represented as
ctl-^, ctl-], and ctl-D, respectively. If I open a command prompt and
scan the label I see all the expected control characters on the entered
line, but in the text box the GS and EOT have been stripped out! Given
that, I am reasonably that either the TextBox or some portion of the
windows key event handling is removing the GS and EOT characters from my
input string.

Arrggghhhh!
Ron L
"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44***********************@news.wanadoo.nl...
Hello, Ron,

I'm not aware of any logic that strips out control characters from a
TextBox. For example, when I type into a multiline textBox using a
keyboard I can easily insert new line characters (<CR><LF>) by typing
<CNTL><Enter>, or other control characters by using Copy/Paste. These
are returned in the Text property.

Also, almost all keystrokes (including the Control keys) are available
via the Key-up events. (As I recall there are a few "navigation" keys
that do not normally appear there, but I think that even these can be
persuaded to appear with a little extra work.)

I wonder if there is something between the scanner driver and the TextBox
that is swallowing the characters you are expecting to see. Do you have
KeyPreview enabled for the Form that contains the TextBox? Or is there
possibly something more sophisticated such as an override of WndProc
interfering?

Anyway, I'm rather doubtful that the problem is with the TextBox.

Cheers,
Randy
Ron L wrote:
Randy

I am using a text box control, but apparently there is logic in that
control that strips out most of the control characters (ASCII values <
32) before entering them into the Text property. I had hoped that by
catching the Key-up event I could somehow "bypass" the code that removes
the control characters.

As far as the scanner is concerned, it is simply acting as if it is a
keyboard and is sending on the characters that were "typed".

Thanks,

Ron L

"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44**********************@news.wanadoo.nl. ..
>Hello, Ron,
>
>I've never worked with a scanner, so please excuse my ignorance. What
>kind of control is it that receives the input? (I had assumed it would
>be something akin to a TextBox and you could just use the Text property
>after completion of the input.)
>
>But when you say that you're catching the key-up event, perhaps the
>processing required is more sophisticated than I realized.
>
>Can you provide any additional information, or perhaps an example of
>the code that you are trying to make work?
>
>Cheers,
>Randy
>
>
>Ron L wrote:
>
>
>>Randy
>>
>>Thanks for the response. My problem is that the scanner acts like a
>>keyboard, so I'm not sure how to get the original informaion into a
>>string in the first place. I have tried catching the key up event,
>>but I haven't figured out what to place in the string to get the
>>control characters into the string. I have printed out the key
>>values, and can't find a correlation between the key value or key code
>>and the control character I am expecting to see.
>>
>>Ron L

Apr 12 '06 #11
Hello, Ron,

I'm at a bit of a loss here. But I'm thinking that the TextBox control
might not be your best solution. I'm afraid that I'm out of my depth
here, and so can't give you much good advice, but here are some
"under-processed" thoughts:

Perhaps you can simply capture the characters that you need in the
IsInputKey or IsCharKey routine and build the "text" string yourself.
You probably don't even need the text box then, just a control of your
own, inherited from Control.

Maybe you'll have to spawn a batch file to capture the input into a text
file and then read that.

Or perhaps you can use something like WndProc to capture the keys at
some lower level.

Have you consulted with the vendor/manufacturer of the barcode scanner
to see if they have any suggestions?

Good luck,
Randy
Ron L wrote:
Randy

Thanks, that definitely was a step in the right direction. I put in both
the IsInputKey and IsInputChar routines (included below) and I now get the
RS character in the final output. I still don't get the GS and EOT
characters, though, even though they are handled in the IsInputChar routine
(I see the debug printouts). I suspect that this is due to a problem with
how I am handling them in the IsInputKey routine. Do you have any other
suggestions?

Thanks again,
Ron L
'********************* ControlCharactersTextBox Class
********************************
Imports System.Windows.Forms

Public Class CtlCharTextBox
Inherits System.Windows.Forms.TextBox

Protected Overrides Function IsInputKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If (keyData And Keys.Control) And (keyData And Keys.D) Then
Debug.WriteLine("IsInputKey: <EOT>")
Return True
ElseIf (keyData And Keys.Control) And (keyData And
Keys.OemCloseBrackets) Then
Debug.WriteLine("IsInputKey: <GS>")
Return True
ElseIf (keyData And Keys.Control) And (keyData And Keys.D6) Then
Debug.WriteLine("IsInputKey: <RS>")
Return True
Else
Return MyBase.IsInputKey(keyData)
End If
End Function

Protected Overrides Function IsInputChar(ByVal charCode As Char) As
Boolean
'Return MyBase.IsInputChar(charCode)
Select Case Asc(charCode)
Case 4 ' EOT character
'Debug.Write(Asc(charCode) & ", " & "<EOT> ")
Return True
Case 29 ' GS character
'Debug.Write(Asc(charCode) & ", " & "<GS> ")
Return True
Case 30 ' RS character
'Debug.Write(Asc(charCode) & ", " & "<RS> ")
Return True
Case Else
'Debug.Write(Asc(charCode) & ", " & charCode & " ")
Return MyBase.IsInputChar(charCode)
End Select
End Function
End Class
"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44**********************@news.wanadoo.nl...
Hello, Ron,

Perhaps these keys are being swallowed by some preprocessing on the form.
Have a look at the help for the "IsInputKey" (and possibly the
"IsInputChar") function. Perhaps they will help you out. I have
previously used the former in order to "capture" some of the navigation
keys. Here is an example of IsInputKey:

Protected Overrides _
Function IsInputKey(ByVal keyData As Keys) As Boolean
' Inhibit pre-processing for selected "special" keys
' that are handled directly by the control.
Select Case keyData
Case Keys.Down, Keys.Left, Keys.Right, Keys.Up
Return (Me.UserMode = aenmUserMode.Design)
Case Else
Return False
End Select

End Function

Cheers,
Randy
Ron L wrote:

Randy

Sorry, I should have been more specific. The text box removes *some* of
the control characters. My string has the RS (ASCII 30), GS (ASCII 29),
and EOT (ASCII 4) embedded in it. These are commonly represented as
ctl-^, ctl-], and ctl-D, respectively. If I open a command prompt and
scan the label I see all the expected control characters on the entered
line, but in the text box the GS and EOT have been stripped out! Given
that, I am reasonably that either the TextBox or some portion of the
windows key event handling is removing the GS and EOT characters from my
input string.

Arrggghhhh!
Ron L
"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44***********************@news.wanadoo.nl. ..
Hello, Ron,

I'm not aware of any logic that strips out control characters from a
TextBox. For example, when I type into a multiline textBox using a
keyboard I can easily insert new line characters (<CR><LF>) by typing
<CNTL><Enter>, or other control characters by using Copy/Paste. These
are returned in the Text property.

Also, almost all keystrokes (including the Control keys) are available
via the Key-up events. (As I recall there are a few "navigation" keys
that do not normally appear there, but I think that even these can be
persuaded to appear with a little extra work.)

I wonder if there is something between the scanner driver and the TextBox
that is swallowing the characters you are expecting to see. Do you have
KeyPreview enabled for the Form that contains the TextBox? Or is there
possibly something more sophisticated such as an override of WndProc
interfering?

Anyway, I'm rather doubtful that the problem is with the TextBox.

Cheers,
Randy
Ron L wrote:

>Randy
>
>I am using a text box control, but apparently there is logic in that
>control that strips out most of the control characters (ASCII values <
>32) before entering them into the Text property. I had hoped that by
>catching the Key-up event I could somehow "bypass" the code that removes
>the control characters.
>
>As far as the scanner is concerned, it is simply acting as if it is a
>keyboard and is sending on the characters that were "typed".
>
>Thanks,
>
>Ron L
>
>"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
>news:44**********************@news.wanadoo.nl ...
>
>
>
>>Hello, Ron,
>>
>>I've never worked with a scanner, so please excuse my ignorance. What
>>kind of control is it that receives the input? (I had assumed it would
>>be something akin to a TextBox and you could just use the Text property
>>after completion of the input.)
>>
>>But when you say that you're catching the key-up event, perhaps the
>>processing required is more sophisticated than I realized.
>>
>>Can you provide any additional information, or perhaps an example of
>>the code that you are trying to make work?
>>
>>Cheers,
>>Randy
>>
>>
>>Ron L wrote:
>>
>>
>>
>>>Randy
>>>
>>>Thanks for the response. My problem is that the scanner acts like a
>>>keyboard, so I'm not sure how to get the original informaion into a
>>>string in the first place. I have tried catching the key up event,
>>>but I haven't figured out what to place in the string to get the
>>>control characters into the string. I have printed out the key
>>>values, and can't find a correlation between the key value or key code
>>>and the control character I am expecting to see.
>>>
>>>Ron L
>
>


Apr 13 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
3
by: deko | last post by:
I store hyperlinks as text in a table like this: Invoice11-21-2003.pdf#file://P:\Finance\PrefVendors\Receipts\Invoice11-21-20 03.pdf I need to run a report that lists the documents - or...
3
by: BC | last post by:
Hi I am trying to display the formated text, a table like, in the tooptip in C#. Something like this: Apple 4 lime 100 I put "\t" after the "Apple". Somehow the tab "\t"...
1
by: Benny Ng | last post by:
Dear All, Now I met one problem in the development of my one application. I have one ASP.NET page. It's for disply the information of customer. But now I have one new requirement. It's to...
0
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Via an ASPX (and code behind) in .net 2.0 I want to be able to "page" though and display the contents of an xml file. So if there are 100 elements, I can display "page 1 of 4" and list 25 elements...
4
by: dgiff33 | last post by:
Hello I am trying to display the characters |, /, - and \ one after the other in the same spot, disappearing and being replaced by the next character so that it looks like a spinning prompt. ...
6
by: =?Utf-8?B?S2Fp?= | last post by:
Hi all, using AJAX Toolkit with vb.net 2.0 how could I make this "Updating..." Screen like e.g. on Codeplex when you click on the "Vote" button...
3
by: WebNewbie | last post by:
Hi, please help I've been wrestling with this for a very long time and its not working. I'm trying to display text files from a database when someone selects one or more list items of my listbox. The...
3
by: kimiraikkonen | last post by:
Hi, I want to display ALL the items (includes unselected items) of listbox control. How can i code this? Should i use "for each" or other? For example: Assume you have a listbox with 3 items...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.