If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Urgent Help with field Input

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-31-04, 20:37
peto813 peto813 is offline
Registered User
 
Join Date: Jun 2004
Posts: 31
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
Reply With Quote
  #2 (permalink)  
Old 09-01-04, 19:19
SCIROCCO SCIROCCO is offline
Registered User
 
Join Date: Mar 2004
Location: www.scirocco.ca
Posts: 346
Put the following code in the KeyPress event of your textbox:

Code:
'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
__________________
http://www.scirocco.ca/images/banner...occobanner.gif

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!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On