CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    May 2013
    Posts
    2

    C# using VB4.0 in Silverlight Application - TextBox input quirky

    I am using the below code and when testing it, the textBoxes will allow number input, but you have to enter the complete number, then arrow back to enter the decimal. Otherwise the cursor jumps in front of the first number and will not allow the decimal to be entered. I would also like to allow the $ to be inputted first.

    Any ideas how I can customize this textBox to do these functions allowing the calculations to function properly given below?

    Code:
    private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
    {
        //Adding ToolTip
        ToolTipService.SetToolTip(textBox1, "Enter Price, numbers first, then arrow back to add decimal.");
    
        if (Double.TryParse(textBox1.Text, out value1))
        {
            textBox1.Text = value1.ToString();
        }
        textBox69.Text = value69.ToString();
        if (textBox1.Text == null || textBox1.Text == "") value1 = 0;
        {
            textBox1.Text = value1.ToString();
    
            if (textBox1.Text.EndsWith(".97") == true)
            {
                value20 = 0; value36 = 0; value69 = 0;
                textBox20.Text = value20.ToString();
                textBox36.Text = value36.ToString();
                textBox69.Text = value69.ToString();
            }
            if (textBox1.Text.EndsWith("1") || textBox1.Text.EndsWith("2") || textBox1.Text.EndsWith("3") || textBox1.Text.EndsWith("4") || textBox1.Text.EndsWith("5") || textBox1.Text.EndsWith("6") || textBox1.Text.EndsWith("8") || textBox1.Text.EndsWith("9") || textBox1.Text.EndsWith("0") == true && (value1 < 100.00))
            {
                value69 = 1;
                textBox69.Text = value69.ToString();
            }
            if (value1 > 100.01 && value1 < 149.99)
                value69 = 2;
            textBox69.Text = value69.ToString();
             }
                if (value1 > 149.99)
                {
                    value69 = 3;
                    textBox69.Text = value69.ToString();
    
        }
    }

  2. #2
    Join Date
    May 2013
    Posts
    2

    Re: C# using VB4.0 in Silverlight Application - TextBox input quirky

    Could I use NumberStyles?
    If so, how would I implement the style to be allowed on the input of the textBox and still do the calculations needed?

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured