3 Replies - 209 Views - Last Post: 17 August 2012 - 08:24 AM Rate Topic: -----

#1 Adidas 777  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 12
  • Joined: 29-July 12

TextBox enable only numbers include doubles

Posted 17 August 2012 - 08:10 AM

Hi
i already have a code that enables hit only numbers to the textbox,

private void SumOfMoney_TextChanged(object sender, TextChangedEventArgs e)
        {
            long a;
            if (long.TryParse(SumOfMoney.Text, out a))
            {
                // If Not Integer Clear Textbox text or you can also Undo() Last Operation :)/>

                SumOfMoney.Clear();
            }
        }



How can I change the code to enable enter number like 4.234 or 234.235

Thanks a lot !!!

Is This A Good Question/Topic? 0
  • +

Replies To: TextBox enable only numbers include doubles

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1690
  • View blog
  • Posts: 2,555
  • Joined: 21-June 11

Re: TextBox enable only numbers include doubles

Posted 17 August 2012 - 08:13 AM

Unless I misunderstood what you want, can't you just replace long in your code with double?
Was This Post Helpful? 1
  • +
  • -

#3 Adidas 777  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 12
  • Joined: 29-July 12

Re: TextBox enable only numbers include doubles

Posted 17 August 2012 - 08:15 AM

I tried but it didn't work :helpsmilie:
Was This Post Helpful? -1
  • +
  • -

#4 Adidas 777  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 12
  • Joined: 29-July 12

Re: TextBox enable only numbers include doubles

Posted 17 August 2012 - 08:24 AM

The code line

if (long.TryParse(SumOfMoney.Text, out a))



Is

if (!long.TryParse(SumOfMoney.Text, out a))



otherwise it do the contrary
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1