Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Limit entries in text box

Posted on 2000-03-19
3
Medium Priority
?
143 Views
Last Modified: 2010-05-02
A pretty dumb question really, but I am trying to limit text box entries to numbers only ?
I also need to allow the decimal point and backspace key to be used in the same text box ?
I can limit the entry to just numbers by using this line of code in the KeyPress event to display an error message if the user enters anything but the numbers 0 to 9.
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
Error message etc.

Help!
0
Comment
Question by:webstudio1
[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
3 Comments
 
LVL 14

Accepted Solution

by:
mcrider earned 400 total points
ID: 2633629
Here you go...

Private Sub Text1_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 8, 46, 48 To 57
            'DO NOTHING
        Case Else
            KeyAscii = 0
    End Select
End Sub


Cheers!®©
0
 

Author Comment

by:webstudio1
ID: 2633678
The obvious really hurts sometimes.
Thanks
Kenny
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2633896
No such thing as a dumb question... ;-)
Thanks for the points! Glad I could help!


Cheers!®©
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 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