MaskedTextBox error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGFvbG8=?=

    #1

    MaskedTextBox error


    I have a maskedtextbox (msktxtbxAmount )defined thus: Mask $#####.## and
    msktxtbxAmount. ValidatingType = typeof(System.D ecimal) with a PromptChar of =.

    I have defined: decimal transAmount and the following event handler:

    private void msktxtbxAmount_ TypeValidationC ompleted(object sender,
    TypeValidationE ventArgs e)
    {
    if (!e.IsValidInpu t)
    {
    MessageBox.Show ("Invalid amount", "Error",
    MessageBoxButto ns.OK);
    }
    else
    {
    transAmount = (decimal)e.Retu rnValue;
    }
    }

    After data entry the text shows "$===35.00" yet I am showing the "Invalid
    Amount" error message.

    Can anyone point out where I have gone wrong?

    Thanks

  • =?Utf-8?B?UGFvbG8=?=

    #2
    RE: MaskedTextBox error

    OK, if I amend the TextMaskFormat property to ExcludePromptsA ndLiterals' the
    input is accepted. However if I input 135.00, what is returned is 13500.

    So how do I get 135.00 to be returned?

    "Paolo" wrote:
    >
    I have a maskedtextbox (msktxtbxAmount )defined thus: Mask $#####.## and
    msktxtbxAmount. ValidatingType = typeof(System.D ecimal) with a PromptChar of =.
    >
    I have defined: decimal transAmount and the following event handler:
    >
    private void msktxtbxAmount_ TypeValidationC ompleted(object sender,
    TypeValidationE ventArgs e)
    {
    if (!e.IsValidInpu t)
    {
    MessageBox.Show ("Invalid amount", "Error",
    MessageBoxButto ns.OK);
    }
    else
    {
    transAmount = (decimal)e.Retu rnValue;
    }
    }
    >
    After data entry the text shows "$===35.00" yet I am showing the "Invalid
    Amount" error message.
    >
    Can anyone point out where I have gone wrong?
    >
    Thanks
    >

    Comment

    • =?Utf-8?B?anAybXNmdA==?=

      #3
      RE: MaskedTextBox error

      Can you divide by 100?

      "Paolo" wrote:
      OK, if I amend the TextMaskFormat property to ExcludePromptsA ndLiterals' the
      input is accepted. However if I input 135.00, what is returned is 13500.
      >
      So how do I get 135.00 to be returned?
      >
      "Paolo" wrote:
      >

      I have a maskedtextbox (msktxtbxAmount )defined thus: Mask $#####.## and
      msktxtbxAmount. ValidatingType = typeof(System.D ecimal) with a PromptChar of =.

      I have defined: decimal transAmount and the following event handler:

      private void msktxtbxAmount_ TypeValidationC ompleted(object sender,
      TypeValidationE ventArgs e)
      {
      if (!e.IsValidInpu t)
      {
      MessageBox.Show ("Invalid amount", "Error",
      MessageBoxButto ns.OK);
      }
      else
      {
      transAmount = (decimal)e.Retu rnValue;
      }
      }

      After data entry the text shows "$===35.00" yet I am showing the "Invalid
      Amount" error message.

      Can anyone point out where I have gone wrong?

      Thanks

      Comment

      • =?Utf-8?B?UGFvbG8=?=

        #4
        RE: MaskedTextBox error

        Yes, that appears to do the trick. Thanks - doh!!!

        "jp2msft" wrote:
        Can you divide by 100?
        >
        "Paolo" wrote:
        >
        OK, if I amend the TextMaskFormat property to ExcludePromptsA ndLiterals' the
        input is accepted. However if I input 135.00, what is returned is 13500.

        So how do I get 135.00 to be returned?

        "Paolo" wrote:
        >
        I have a maskedtextbox (msktxtbxAmount )defined thus: Mask $#####.## and
        msktxtbxAmount. ValidatingType = typeof(System.D ecimal) with a PromptChar of =.
        >
        I have defined: decimal transAmount and the following event handler:
        >
        private void msktxtbxAmount_ TypeValidationC ompleted(object sender,
        TypeValidationE ventArgs e)
        {
        if (!e.IsValidInpu t)
        {
        MessageBox.Show ("Invalid amount", "Error",
        MessageBoxButto ns.OK);
        }
        else
        {
        transAmount = (decimal)e.Retu rnValue;
        }
        }
        >
        After data entry the text shows "$===35.00" yet I am showing the "Invalid
        Amount" error message.
        >
        Can anyone point out where I have gone wrong?
        >
        Thanks
        >

        Comment

        Working...