keypress question

S

starbuck

Hi All



We are converting a VB6 app to VB.NET and have come across a little problem

In VB6 the following code



Private Sub User_txt_KeyPress(KeyAscii As Integer)

KeyAscii = Key_Filter_Alpha(KeyAscii)

End Sub



Calls



Function Key_Filter_Alpha(keyc%) As Integer



Select Case keyc%

Case 32

Case 3 'Ctrl C

Case 24 'Ctrl X

Case 8 'BackSpace

Case 48 To 57 'Number 0-9

Case 65 To 90 'A-Z

Case 97 To 122 'a-z

keyc% = keyc% - 32

Case Else

keyc% = 0

End Select



Key_Filter_Alpha = keyc%



End Function



And only returns upper case letters, nothing else. We can not seem to get
this to work in VB.NET, and ideas, hints etc.



Thanks in advance.
 
H

Herfried K. Wagner [MVP]

* "starbuck said:
We are converting a VB6 app to VB.NET and have come across a little problem

In VB6 the following code



Private Sub User_txt_KeyPress(KeyAscii As Integer)

KeyAscii = Key_Filter_Alpha(KeyAscii)

End Sub

Instead of preventing the user from typing into the textbox whatever
he/she wants, add validation code to the textbox's 'Validating' event
handler and set an ErrorProvider (see Toolbox).
 
S

starbuck

That's cool, thanks



Herfried K. Wagner said:
Instead of preventing the user from typing into the textbox whatever
he/she wants, add validation code to the textbox's 'Validating' event
handler and set an ErrorProvider (see Toolbox).
 
K

Ken Tucker [MVP]

Hi,

In addition to Herfried's comments you can set the textbox's
charactercasing to charactercasing.upper if you only want upper case
letters.

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top