473,385 Members | 1,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How do i control the user input to a textbox that only accepts int ? C# please

sword117
i already got this.
Expand|Select|Wrap|Line Numbers
  1.  private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  2.         {
  3.      int ascii = Convert.ToInt16(e.KeyChar);
  4.             if ((ascii >= 48 && ascii <= 57) || (ascii == 8) || (ascii==32))
  5.             {
  6.  
  7.                 e.Handled = false;
  8.  
  9.             }
  10.  
  11.             else
  12.             {
  13.  
  14.                 e.Handled = true;
  15.  
  16.             }
  17. }
  18.  
Jun 18 '10 #1
0 790

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: deko | last post by:
Is there a way to check user input for illegal characters? For example, a user enters something into a text box and clicks OK. At that point I'd like to run code such as this: illegal =...
6
by: Maziar Aflatoun | last post by:
Hi, I have a little application that reads a text file line-by-line and processes each line depending on the CVS values. Now I want to change my program to capture this from a textbox. How do...
1
by: cw | last post by:
Hi all, Is anyone have an idea that limit message length input by user into textbox. I'hv tried the maxlength property by setting it to 150, but it seems like not working.., regards
2
by: charleswesley | last post by:
I find myself regularly needing to validate user input as either a) numeric only or b) valid email address format (user@domain.tld) I am assuming that there are regular expressions that can be...
0
by: Paulers | last post by:
hello VB masters I have an issue that I am hoping you can help me with. I am creating an application that accepts user input via a richtextbox. the user can enter multiple entries and I need to...
2
by: Matt | last post by:
Hi, I'm ridiculously new to Access (about a week!) so please be patient! My database is a record of British Standards. Each has a unique identifier. Some are split into parts. I would like...
2
by: wertqt | last post by:
hi there, im having a slight problem in matching the user input(textbox's text) with the values in one of the columns from a MS Access database. Im using C#.NET. The situation is this : My...
0
by: bijuvarghese576 | last post by:
I made a user control in which i used a textbox which accepts only numeric only. I tested and it is working fine. I used this user control in my FORM and bound it with a data field, it shows value...
29
parshupooja
by: parshupooja | last post by:
Hi, I am working in Asp.Net 2.0, SQL Server, C#. I am trying to create a User Input form which has lots of fields such as : salutation; Firstname: lastname: address: Zip: Phone:
2
by: Carin Botha | last post by:
I want to create a Stored Procedure or a view and ask for user input. Example: Select name from partner where code = 'User Input'. Could you help please?
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.