Solved

Isnumeric

Posted on 2000-02-27
5
135 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
[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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…

736 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