Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004

    Unanswered: Urgent Help with field Input

    I am creating an application using Visual Basic 2005 (similar to .net)that reads values from a set of fields in order to perform numerical calculations. My question is the following, how can I prevent users or at least display a messagebox whenever users enter characters other than numerical characters?
    Thank you in advance

  2. #2
    Join Date
    Mar 2004
    Put the following code in the KeyPress event of your textbox:

    'The User Pressed Enter
    If KeyAscii = 13 Then
        'Do your processing code here
    'The user pressed non numeric character. Cancel the entry.
    ElseIf KeyAscii <> 8 And (KeyAscii < 48 Or KeyAscii > 57) Then
        KeyAscii = 0
    End If

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts