Reputation: 1393
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:
Upvotes: 1
Views: 126
Reputation: 2992
Alright, the problem is your PrompChar:0, all 0s will be treated as prompt character and discarded from value.
To solve it, do either
GOOG Luck!!
Upvotes: 2
Reputation: 993
you must convert it to integer then try this...:
Cint(mtPig.Text)
or
Convert.ToInt32(mtPig.Text)
Upvotes: 0
Reputation: 117084
Try this:
For i As Integer = 0 To Integer.Parse(mtPig.Text)
MessageBox.Show(i)
Next
Upvotes: 2
Reputation: 62111
For loop doesn't recognize 10 as ten
No, For loop does not magically transform a string to an int.
Cast, convert, do it in code. But do not assume the compiler will magically do converts.
Upvotes: 1