Solved

Isnumeric

Posted on 2000-02-27
5
132 Views
Last Modified: 2010-05-02
I have a calculation field where there should only be a numeric input.  I suppose there should be an isnumeric verification on the change event but I'm not sure how to write it.
0
Comment
Question by:douglaskarr
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
Vbmaster earned 10 total points
ID: 2562729
Here's a easy way to not allow the end user to enter any non-digits value into a textbox..

  Private Sub Text1_KeyPress(KeyAscii As Integer)

    If Not ((KeyAscii >= vbKey0) And (KeyAscii <= vbKey9)) Then
      KeyAscii = 0
    End If

  End Sub

This will only allow the keys 0 to 9.
0
 

Author Comment

by:douglaskarr
ID: 2562745
Thanks!
0
 

Author Comment

by:douglaskarr
ID: 2562750
Hold on... what about decimals?  ie: 5.1
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2562829
This would be a solution, it checks to make sure the input is numerical values and it will allow one decimal point (46 is the ascii code for the '.' character)...

  If Not ((KeyAscii >= vbKey0) And (KeyAscii <= vbKey9)) Then
    If Not ((KeyAscii = 46) And (InStr(Text1, ".") = 0)) Then
      KeyAscii = 0
    End If
  End If
0
 

Author Comment

by:douglaskarr
ID: 2562881
Thank-you very much...

Doug
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to add contact name to VBA code to automate emails in outlook using a Template 11 84
vbModal 12 53
Advice in Xamarin 21 80
VBA - If Bookmark = "XXBOOKMARKXX" then 15 29
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 some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

821 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