Solved

Visual Studio Tools for office 2005 KeyPress event

Posted on 2007-11-20
2
401 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

735 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