Solved

Visual Studio Tools for office 2005 KeyPress event

Posted on 2007-11-20
2
396 Views
Last Modified: 2013-11-26
Hi

I am converting an Excel VBA project to Visual Studio Tools for Office 2005.
In the VBA project I use the following code in the KeyPress event of a text box
to prevent anything other than numbers being typed in
        'If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
What is the equivalent code in Visual Studio 2005 VB?

Thanks
0
Comment
Question by:murbro
2 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20325715
do something like:

If e.KeyChar < Convert.ToChar(48) Or e.KeyChar > Convert.ToChar(57) Then e.KeyChar = Convert.ToChar(0)

where 'e' represent the KeyPressEventArgs argument
0
 

Author Closing Comment

by:murbro
ID: 31410303
Thanks Jaime. Excellent answer!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with deleting records in file1 in data in found in file2 using VB.NET 5 43
Access Web appliction 7 48
asp.net mvc input file 2 32
Host asp.net pages 5 25
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now