TextBox - what is going wrong?

  • Thread starter Thread starter M O J O
  • Start date Start date
M

M O J O

Hi,

I have a TextBox on my form.

I capture the KeyDown event and examines the e.KeyValue - that is, I
examine it like this: dim chr = chr(KeyValue).

This seams to work ok .... well almost.

In Denmark we have some special characters like this one (hope you can
see it): "ø", which is a circle with a line through it.

The text box writes the special characters without any problem, but the
chr(e.KeyValue) shows a strange character and e.KeyCOde & e.KeyData
writes OemQuotes.

What is going on here? Do I have to set some kind of localize info??

Thanks!!

M O J O
 
M O J O said:
Hi,

I have a TextBox on my form.

I capture the KeyDown event and examines the e.KeyValue - that is, I
examine it like this: dim chr = chr(KeyValue).

This seams to work ok .... well almost.

In Denmark we have some special characters like this one (hope you can
see it): "ø", which is a circle with a line through it.

The text box writes the special characters without any problem, but the
chr(e.KeyValue) shows a strange character and e.KeyCOde & e.KeyData
writes OemQuotes.

What is going on here? Do I have to set some kind of localize info??

Wierd, it works for me (ø = ALT+0248) - when I key it into a text box, it
works with the following code just fine (KeyPress):

Debug.WriteLine(e.KeyChar)
If e.KeyChar = Chr(248) Then
MsgBox(e.KeyChar)
End If

But since I don't have a keyboard that has that symbol, I can't test with
key-down... So I guess this is no help. Sorry.

Jeremy
 
M O J O said:
I have a TextBox on my form.

I capture the KeyDown event and examines the e.KeyValue - that is, I
examine it like this: dim chr = chr(KeyValue).

This seams to work ok .... well almost.

In Denmark we have some special characters like this one (hope you
can see it): "ø", which is a circle with a line through it.

The text box writes the special characters without any problem, but
the chr(e.KeyValue) shows a strange character and e.KeyCOde &
e.KeyData writes OemQuotes.

What is going on here? Do I have to set some kind of localize
info??

Keydown is used to receive keys, not chars. Use Keypress to evaluate chars.
Keyvalues are not character values. For example, pressing the "A" key fires
keydown with keycode = Keys.A, but the resulting char might be "a", "A", or
chr(1) depending on the state of the shift and ctrl keys. Another example:
function keys. They produce keydown events but no keypress events because
they are not translated to chars.

Armin
 
Back
Top