Advertisement

06.24.2008 at 11:51PM PDT, ID: 23513518
[x]
Attachment Details

how to allow textbox to acccept only numbers and decimal point?

Asked by Fahed_Ahmed_Shaik in Microsoft Visual J#.Net

Tags: .Net C#

i want to enter price value in my textbox.i want it to accept only numbers and one decimal point.right now its taking only numbers but not decimal point.the code i hav written is given below bt its only to accept numbers not decimal point.
 string s = txtPrice.Text;
            int chars = s.Length;
           // char p = '.';
            for (int i = 0; i < chars; i++)
            {
                if (!char.IsNumber(s, i))
                {                
                        MessageBox.Show("Enter only numbers");
                        txtPrice.Text = s.Remove(i, 1);
                        txtPrice.Select(txtPrice.Text.Length, 0);
                        return;                  
                }Start Free Trial
[+][-]06.25.2008 at 08:34AM PDT, ID: 21866793

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual J#.Net
Tags: .Net C#
Sign Up Now!
Solution Provided By: TheLearnedOne
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.16.2008 at 02:47PM PDT, ID: 22020531

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]08.17.2008 at 08:23AM PDT, ID: 22247239

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]08.22.2008 at 05:27PM PDT, ID: 22295139

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628