Search code examples
.netvb.netfor-loopmaskedtextbox

Masked TextBox doesn't recognize 10 as ten


For i As Integer = 0 To mtPig.Text
        MessageBox.Show(i)
    Next

I used a MaskedTextBox with a 2-digit mask.
If I put 10, it shows 0 and 1.
If I put 9, it shows 0-9.

Why doesn't it read the zero next to one? (10)
How can I make 10 read as ten?
UPDATE:
enter image description here


Solution

  • Alright, the problem is your PrompChar:0, all 0s will be treated as prompt character and discarded from value.

    To solve it, do either

    • change your PromptChar to _ (underscore)
    • or set the MaskedTextbox property named TextMaskFormat to IncludePrompt

    GOOG Luck!!