473,396 Members | 1,968 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,396 software developers and data experts.

keypress question

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.




---
Outgoing mail is certified Virus Free, so am I.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004
Nov 20 '05 #1
3 1475
* "starbuck" <st******@mbssoft.co.uk> scripsit:
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).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
That's cool, thanks

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c1*************@ID-208219.news.uni-berlin.de...
* "starbuck" <st******@mbssoft.co.uk> scripsit:
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).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

---
Outgoing mail is certified Virus Free, so am I.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004
Nov 20 '05 #3
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
------------
"starbuck" <st******@mbssoft.co.uk> wrote in message
news:eq****************@TK2MSFTNGP09.phx.gbl...
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.




---
Outgoing mail is certified Virus Free, so am I.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004

Nov 20 '05 #4

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

Similar topics

1
by: dave | last post by:
I've designed a nice little App that works something like a spreadsheet using the MSHFlexgrid control. Many users are inclined to press the tab key, expecting the program to respond like excel...
4
by: phil_gg04 | last post by:
Dear Javascript Experts, I'm currently implementing Anyterm, a terminal emulator on a web page. It consists of an Apache module, some XmlHTTP and a bit of Javascript. The idea is to give you...
1
by: Darren Coleman | last post by:
I need help with 2 keyboard/input questions 1. How do i caputre all keypress events for my application/form? 2. How do I determine which keyboard sent the keypress? What i'm doing is using a...
3
by: Terry Olsen | last post by:
Is there anyway to cause a KeyPress event in a datagrid cell? The only way I get a keypress event is if none of the cells are selected. I was hoping to have the program respond to a certain...
3
by: Just Me | last post by:
I noticed that I don't get KeyDown nor KetPress events if NumLock is not on. I can probably find a workaround but it would be nice to know what the rules are. Can anyone tell me when KeyPress...
3
by: Nikolay Evseev | last post by:
Hi, I am trying to trace down the Enter key in my Form.KeyPress event handler. The KeyPreview property is set to false, so I'd assume that all key presses should go through my form's KeyPress...
2
by: Bob | last post by:
In that event, how can you find out if the keypress event was in a certain column? Say you have datagridview1, columnname1, columnName2 You want to do something only with the keypress event of...
5
by: Henry Jones | last post by:
I am new to C# and wanted to capture the KeyPress for a textbox. I created some code as follows: private void textBox3_KeyPress(object sender, System.EventArgs e) { this.textBox2.Text =...
4
by: Jeff | last post by:
....still new at this. ...hopefully a simple question Is there some practical way of altering the function of a keypress in Visual Web.net 2005 using VB without causing a postback on each...
2
by: Tony Johansson | last post by:
Hello! I have created a Control that consist of a label and a textbox.I have called this class ctlLabelTextbox. public partial class ctlLabelTextbox : UserControl { .... } The class that I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.