Solved

Visual Studio Tools for office 2005 KeyPress event

Posted on 2007-11-20
2
393 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

12 Experts available now in Live!

Get 1:1 Help Now