keypress question

  • Thread starter Thread starter starbuck
  • Start date Start date
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.
 
* "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).
 
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).
 
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
 
Back
Top